Lines Matching +full:fifo +full:- +full:size

1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2 /* Copyright(c) 2018-2019 Realtek Corporation
94 return -ETIMEDOUT; in rtw_mac_pre_system_cfg()
107 return -EINVAL; in rtw_mac_pre_system_cfg()
156 if (cmd->base == RTW_PWR_ADDR_SDIO) in rtw_pwr_cmd_polling()
157 offset = cmd->offset | SDIO_LOCAL_OFFSET; in rtw_pwr_cmd_polling()
159 offset = cmd->offset; in rtw_pwr_cmd_polling()
161 if (do_pwr_poll_cmd(rtwdev, offset, cmd->mask, cmd->value)) in rtw_pwr_cmd_polling()
169 if (rtwdev->chip->id == RTW_CHIP_TYPE_8723D) in rtw_pwr_cmd_polling()
173 if (rtwdev->chip->id == RTW_CHIP_TYPE_8723D) in rtw_pwr_cmd_polling()
176 if (do_pwr_poll_cmd(rtwdev, offset, cmd->mask, cmd->value)) in rtw_pwr_cmd_polling()
181 offset, cmd->mask, cmd->value); in rtw_pwr_cmd_polling()
182 return -EBUSY; in rtw_pwr_cmd_polling()
193 for (cur_cmd = cmd; cur_cmd->cmd != RTW_PWR_CMD_END; cur_cmd++) { in rtw_sub_pwr_seq_parser()
194 if (!(cur_cmd->intf_mask & intf_mask) || in rtw_sub_pwr_seq_parser()
195 !(cur_cmd->cut_mask & cut_mask)) in rtw_sub_pwr_seq_parser()
198 switch (cur_cmd->cmd) { in rtw_sub_pwr_seq_parser()
200 offset = cur_cmd->offset; in rtw_sub_pwr_seq_parser()
202 if (cur_cmd->base == RTW_PWR_ADDR_SDIO) in rtw_sub_pwr_seq_parser()
206 value &= ~cur_cmd->mask; in rtw_sub_pwr_seq_parser()
207 value |= (cur_cmd->value & cur_cmd->mask); in rtw_sub_pwr_seq_parser()
212 return -EBUSY; in rtw_sub_pwr_seq_parser()
215 if (cur_cmd->value == RTW_PWR_DELAY_US) in rtw_sub_pwr_seq_parser()
216 udelay(cur_cmd->offset); in rtw_sub_pwr_seq_parser()
218 mdelay(cur_cmd->offset); in rtw_sub_pwr_seq_parser()
223 return -EINVAL; in rtw_sub_pwr_seq_parser()
240 cut = rtwdev->hal.cut_version; in rtw_pwr_seq_parser()
253 return -EINVAL; in rtw_pwr_seq_parser()
273 const struct rtw_chip_info *chip = rtwdev->chip; in rtw_mac_power_switch()
281 rpwm = rtw_read8(rtwdev, rtwdev->hci.rpwm_addr); in rtw_mac_power_switch()
286 rtw_write8(rtwdev, rtwdev->hci.rpwm_addr, rpwm); in rtw_mac_power_switch()
299 return -EALREADY; in rtw_mac_power_switch()
307 clear_bit(RTW_FLAG_POWERON, rtwdev->flags); in rtw_mac_power_switch()
309 pwr_seq = pwr_on ? chip->pwr_on_seq : chip->pwr_off_seq; in rtw_mac_power_switch()
313 if (chip->id == RTW_CHIP_TYPE_8822C || in rtw_mac_power_switch()
314 chip->id == RTW_CHIP_TYPE_8822B || in rtw_mac_power_switch()
315 chip->id == RTW_CHIP_TYPE_8821C) in rtw_mac_power_switch()
323 set_bit(RTW_FLAG_POWERON, rtwdev->flags); in rtw_mac_power_switch()
330 u8 sys_func_en = rtwdev->chip->sys_func_en; in __rtw_mac_init_system_cfg()
342 /* disable boot-from-flash for driver's DL FW */ in __rtw_mac_init_system_cfg()
385 if (ret == -EALREADY) { in rtw_mac_power_on()
415 static bool check_firmware_size(const u8 *data, u32 size) in check_firmware_size() argument
423 dmem_size = le32_to_cpu(fw_hdr->dmem_size); in check_firmware_size()
424 imem_size = le32_to_cpu(fw_hdr->imem_size); in check_firmware_size()
425 emem_size = (fw_hdr->mem_usage & BIT(4)) ? in check_firmware_size()
426 le32_to_cpu(fw_hdr->emem_size) : 0; in check_firmware_size()
432 if (real_size != size) in check_firmware_size()
494 rtw_write32(rtwdev, REG_RQPN_CTRL_2, bckp[bckp_idx - 1].val); in download_firmware_reg_backup()
529 const u8 *data, u32 size) in send_firmware_pkt_rsvd_page() argument
534 buf = kmemdup(data, size, GFP_KERNEL); in send_firmware_pkt_rsvd_page()
536 return -ENOMEM; in send_firmware_pkt_rsvd_page()
538 ret = rtw_fw_write_data_rsvd_page(rtwdev, pg_addr, buf, size); in send_firmware_pkt_rsvd_page()
544 send_firmware_pkt(struct rtw_dev *rtwdev, u16 pg_addr, const u8 *data, u32 size) in send_firmware_pkt() argument
549 !((size + TX_DESC_SIZE) & (512 - 1))) in send_firmware_pkt()
550 size += 1; in send_firmware_pkt()
552 ret = send_firmware_pkt_rsvd_page(rtwdev, pg_addr, data, size); in send_firmware_pkt()
567 return -EBUSY; in iddma_enable()
578 return -EBUSY; in iddma_download_firmware()
585 return -EBUSY; in iddma_download_firmware()
590 int rtw_ddma_to_fw_fifo(struct rtw_dev *rtwdev, u32 ocp_src, u32 size) in rtw_ddma_to_fw_fifo() argument
596 return -EBUSY; in rtw_ddma_to_fw_fifo()
599 ch0_ctrl |= size & BIT_MASK_DDMACH0_DLEN; in rtw_ddma_to_fw_fifo()
603 return -EBUSY; in rtw_ddma_to_fw_fifo()
645 u32 src, u32 dst, u32 size) in download_firmware_to_mem() argument
647 const struct rtw_chip_info *chip = rtwdev->chip; in download_firmware_to_mem()
648 u32 desc_size = chip->tx_pkt_desc_sz; in download_firmware_to_mem()
659 residue_size = size; in download_firmware_to_mem()
685 residue_size -= pkt_size; in download_firmware_to_mem()
689 return -EINVAL; in download_firmware_to_mem()
695 start_download_firmware(struct rtw_dev *rtwdev, const u8 *data, u32 size) in start_download_firmware() argument
706 dmem_size = le32_to_cpu(fw_hdr->dmem_size); in start_download_firmware()
707 imem_size = le32_to_cpu(fw_hdr->imem_size); in start_download_firmware()
708 emem_size = (fw_hdr->mem_usage & BIT(4)) ? in start_download_firmware()
709 le32_to_cpu(fw_hdr->emem_size) : 0; in start_download_firmware()
719 addr = le32_to_cpu(fw_hdr->dmem_addr); in start_download_firmware()
726 addr = le32_to_cpu(fw_hdr->imem_addr); in start_download_firmware()
734 addr = le32_to_cpu(fw_hdr->emem_addr); in start_download_firmware()
753 return -EINVAL; in download_firmware_validate()
778 const u8 *data = fw->firmware->data; in __rtw_download_firmware()
779 u32 size = fw->firmware->size; in __rtw_download_firmware() local
783 if (!check_firmware_size(data, size)) in __rtw_download_firmware()
784 return -EINVAL; in __rtw_download_firmware()
787 return -EBUSY; in __rtw_download_firmware()
794 ret = start_download_firmware(rtwdev, data, size); in __rtw_download_firmware()
805 ret = -EBUSY; in __rtw_download_firmware()
816 rtwdev->h2c.last_box_num = 0; in __rtw_download_firmware()
817 rtwdev->h2c.seq = 0; in __rtw_download_firmware()
819 set_bit(RTW_FLAG_FW_RUNNING, rtwdev->flags); in __rtw_download_firmware()
856 write_firmware_page(struct rtw_dev *rtwdev, u32 page, const u8 *data, u32 size) in write_firmware_page() argument
866 block_nr = size >> DLFW_BLK_SIZE_SHIFT_LEGACY; in write_firmware_page()
867 remain_size = size & (DLFW_BLK_SIZE_LEGACY - 1); in write_firmware_page()
888 download_firmware_legacy(struct rtw_dev *rtwdev, const u8 *data, u32 size) in download_firmware_legacy() argument
895 size -= sizeof(struct rtw_fw_hdr_legacy); in download_firmware_legacy()
897 total_page = size >> DLFW_PAGE_SIZE_SHIFT_LEGACY; in download_firmware_legacy()
898 last_page_size = size & (DLFW_PAGE_SIZE_LEGACY - 1); in download_firmware_legacy()
911 return -EINVAL; in download_firmware_legacy()
938 return -EINVAL; in download_firmware_validate_legacy()
947 if (rtwdev->chip->id == RTW_CHIP_TYPE_8703B && in __rtw_download_firmware_legacy()
953 ret = download_firmware_legacy(rtwdev, fw->firmware->data, fw->firmware->size); in __rtw_download_firmware_legacy()
965 rtwdev->h2c.last_box_num = 0; in __rtw_download_firmware_legacy()
966 rtwdev->h2c.seq = 0; in __rtw_download_firmware_legacy()
968 set_bit(RTW_FLAG_FW_RUNNING, rtwdev->flags); in __rtw_download_firmware_legacy()
992 rtwdev->chip->id == RTW_CHIP_TYPE_8821C) in rtw_download_firmware()
1000 const struct rtw_rqpn *rqpn = rtwdev->fifo.rqpn; in get_priority_queues()
1004 prio_queues |= BIT(rqpn->dma_map_vo); in get_priority_queues()
1006 prio_queues |= BIT(rqpn->dma_map_vi); in get_priority_queues()
1008 prio_queues |= BIT(rqpn->dma_map_be); in get_priority_queues()
1010 prio_queues |= BIT(rqpn->dma_map_bk); in get_priority_queues()
1018 const struct rtw_chip_info *chip = rtwdev->chip; in __rtw_mac_flush_prio_queue()
1027 addr = &chip->prioq_addrs->prio[prio_queue]; in __rtw_mac_flush_prio_queue()
1028 wsize = chip->prioq_addrs->wsize; in __rtw_mac_flush_prio_queue()
1032 rsvd_page = wsize ? rtw_read16(rtwdev, addr->rsvd) : in __rtw_mac_flush_prio_queue()
1033 rtw_read8(rtwdev, addr->rsvd); in __rtw_mac_flush_prio_queue()
1034 avail_page = wsize ? rtw_read16(rtwdev, addr->avail) : in __rtw_mac_flush_prio_queue()
1035 rtw_read8(rtwdev, addr->avail); in __rtw_mac_flush_prio_queue()
1071 if (queues == BIT(rtwdev->hw->queues) - 1 || !rtwdev->fifo.rqpn) in rtw_mac_flush_queues()
1072 prio_queues = BIT(RTW_DMA_MAPPING_MAX) - 1; in rtw_mac_flush_queues()
1081 const struct rtw_chip_info *chip = rtwdev->chip; in txdma_queue_mapping()
1087 rqpn = &chip->rqpn_table[1]; in txdma_queue_mapping()
1090 if (rtwdev->hci.bulkout_num == 2) in txdma_queue_mapping()
1091 rqpn = &chip->rqpn_table[2]; in txdma_queue_mapping()
1092 else if (rtwdev->hci.bulkout_num == 3) in txdma_queue_mapping()
1093 rqpn = &chip->rqpn_table[3]; in txdma_queue_mapping()
1094 else if (rtwdev->hci.bulkout_num == 4) in txdma_queue_mapping()
1095 rqpn = &chip->rqpn_table[4]; in txdma_queue_mapping()
1097 return -EINVAL; in txdma_queue_mapping()
1100 rqpn = &chip->rqpn_table[0]; in txdma_queue_mapping()
1103 return -EINVAL; in txdma_queue_mapping()
1106 rtwdev->fifo.rqpn = rqpn; in txdma_queue_mapping()
1107 txdma_pq_map |= BIT_TXDMA_HIQ_MAP(rqpn->dma_map_hi); in txdma_queue_mapping()
1108 txdma_pq_map |= BIT_TXDMA_MGQ_MAP(rqpn->dma_map_mg); in txdma_queue_mapping()
1109 txdma_pq_map |= BIT_TXDMA_BKQ_MAP(rqpn->dma_map_bk); in txdma_queue_mapping()
1110 txdma_pq_map |= BIT_TXDMA_BEQ_MAP(rqpn->dma_map_be); in txdma_queue_mapping()
1111 txdma_pq_map |= BIT_TXDMA_VIQ_MAP(rqpn->dma_map_vi); in txdma_queue_mapping()
1112 txdma_pq_map |= BIT_TXDMA_VOQ_MAP(rqpn->dma_map_vo); in txdma_queue_mapping()
1132 const struct rtw_chip_info *chip = rtwdev->chip; in set_trx_fifo_info()
1133 struct rtw_fifo_conf *fifo = &rtwdev->fifo; in set_trx_fifo_info() local
1135 u8 csi_buf_pg_num = chip->csi_buf_pg_num; in set_trx_fifo_info()
1138 fifo->rsvd_drv_pg_num = chip->rsvd_drv_pg_num; in set_trx_fifo_info()
1139 fifo->txff_pg_num = chip->txff_size >> 7; in set_trx_fifo_info()
1141 fifo->rsvd_pg_num = fifo->rsvd_drv_pg_num; in set_trx_fifo_info()
1143 fifo->rsvd_pg_num = fifo->rsvd_drv_pg_num + in set_trx_fifo_info()
1151 if (fifo->rsvd_pg_num > fifo->txff_pg_num) in set_trx_fifo_info()
1152 return -ENOMEM; in set_trx_fifo_info()
1154 fifo->acq_pg_num = fifo->txff_pg_num - fifo->rsvd_pg_num; in set_trx_fifo_info()
1155 fifo->rsvd_boundary = fifo->txff_pg_num - fifo->rsvd_pg_num; in set_trx_fifo_info()
1157 cur_pg_addr = fifo->txff_pg_num; in set_trx_fifo_info()
1159 cur_pg_addr -= csi_buf_pg_num; in set_trx_fifo_info()
1160 fifo->rsvd_csibuf_addr = cur_pg_addr; in set_trx_fifo_info()
1161 cur_pg_addr -= RSVD_PG_FW_TXBUF_NUM; in set_trx_fifo_info()
1162 fifo->rsvd_fw_txbuf_addr = cur_pg_addr; in set_trx_fifo_info()
1163 cur_pg_addr -= RSVD_PG_CPU_INSTRUCTION_NUM; in set_trx_fifo_info()
1164 fifo->rsvd_cpu_instr_addr = cur_pg_addr; in set_trx_fifo_info()
1165 cur_pg_addr -= RSVD_PG_H2CQ_NUM; in set_trx_fifo_info()
1166 fifo->rsvd_h2cq_addr = cur_pg_addr; in set_trx_fifo_info()
1167 cur_pg_addr -= RSVD_PG_H2C_STATICINFO_NUM; in set_trx_fifo_info()
1168 fifo->rsvd_h2c_sta_info_addr = cur_pg_addr; in set_trx_fifo_info()
1169 cur_pg_addr -= RSVD_PG_H2C_EXTRAINFO_NUM; in set_trx_fifo_info()
1170 fifo->rsvd_h2c_info_addr = cur_pg_addr; in set_trx_fifo_info()
1172 cur_pg_addr -= fifo->rsvd_drv_pg_num; in set_trx_fifo_info()
1173 fifo->rsvd_drv_addr = cur_pg_addr; in set_trx_fifo_info()
1175 if (fifo->rsvd_boundary != fifo->rsvd_drv_addr) { in set_trx_fifo_info()
1177 return -EINVAL; in set_trx_fifo_info()
1187 const struct rtw_chip_info *chip = rtwdev->chip; in __priority_queue_cfg()
1188 struct rtw_fifo_conf *fifo = &rtwdev->fifo; in __priority_queue_cfg() local
1190 rtw_write16(rtwdev, REG_FIFOPAGE_INFO_1, pg_tbl->hq_num); in __priority_queue_cfg()
1191 rtw_write16(rtwdev, REG_FIFOPAGE_INFO_2, pg_tbl->lq_num); in __priority_queue_cfg()
1192 rtw_write16(rtwdev, REG_FIFOPAGE_INFO_3, pg_tbl->nq_num); in __priority_queue_cfg()
1193 rtw_write16(rtwdev, REG_FIFOPAGE_INFO_4, pg_tbl->exq_num); in __priority_queue_cfg()
1197 rtw_write16(rtwdev, REG_FIFOPAGE_CTRL_2, fifo->rsvd_boundary); in __priority_queue_cfg()
1200 rtw_write16(rtwdev, REG_BCNQ_BDNY_V1, fifo->rsvd_boundary); in __priority_queue_cfg()
1201 rtw_write16(rtwdev, REG_FIFOPAGE_CTRL_2 + 2, fifo->rsvd_boundary); in __priority_queue_cfg()
1202 rtw_write16(rtwdev, REG_BCNQ1_BDNY_V1, fifo->rsvd_boundary); in __priority_queue_cfg()
1203 rtw_write32(rtwdev, REG_RXFF_BNDY, chip->rxff_size - C2H_PKT_BUF - 1); in __priority_queue_cfg()
1205 if (rtwdev->hci.type == RTW_HCI_TYPE_USB) { in __priority_queue_cfg()
1207 chip->usb_tx_agg_desc_num); in __priority_queue_cfg()
1209 rtw_write8(rtwdev, REG_AUTO_LLT_V1 + 3, chip->usb_tx_agg_desc_num); in __priority_queue_cfg()
1216 return -EBUSY; in __priority_queue_cfg()
1227 const struct rtw_chip_info *chip = rtwdev->chip; in __priority_queue_cfg_legacy()
1228 struct rtw_fifo_conf *fifo = &rtwdev->fifo; in __priority_queue_cfg_legacy() local
1231 val32 = BIT_RQPN_NE(pg_tbl->nq_num, pg_tbl->exq_num); in __priority_queue_cfg_legacy()
1233 val32 = BIT_RQPN_HLP(pg_tbl->hq_num, pg_tbl->lq_num, pubq_num); in __priority_queue_cfg_legacy()
1236 rtw_write8(rtwdev, REG_TRXFF_BNDY, fifo->rsvd_boundary); in __priority_queue_cfg_legacy()
1237 rtw_write16(rtwdev, REG_TRXFF_BNDY + 2, chip->rxff_size - REPORT_BUF - 1); in __priority_queue_cfg_legacy()
1238 rtw_write8(rtwdev, REG_DWBCN0_CTRL + 1, fifo->rsvd_boundary); in __priority_queue_cfg_legacy()
1239 rtw_write8(rtwdev, REG_BCNQ_BDNY, fifo->rsvd_boundary); in __priority_queue_cfg_legacy()
1240 rtw_write8(rtwdev, REG_MGQ_BDNY, fifo->rsvd_boundary); in __priority_queue_cfg_legacy()
1241 rtw_write8(rtwdev, REG_WMAC_LBK_BF_HD, fifo->rsvd_boundary); in __priority_queue_cfg_legacy()
1246 return -EBUSY; in __priority_queue_cfg_legacy()
1253 const struct rtw_chip_info *chip = rtwdev->chip; in priority_queue_cfg()
1254 struct rtw_fifo_conf *fifo = &rtwdev->fifo; in priority_queue_cfg() local
1265 pg_tbl = &chip->page_table[1]; in priority_queue_cfg()
1268 if (rtwdev->hci.bulkout_num == 2) in priority_queue_cfg()
1269 pg_tbl = &chip->page_table[2]; in priority_queue_cfg()
1270 else if (rtwdev->hci.bulkout_num == 3) in priority_queue_cfg()
1271 pg_tbl = &chip->page_table[3]; in priority_queue_cfg()
1272 else if (rtwdev->hci.bulkout_num == 4) in priority_queue_cfg()
1273 pg_tbl = &chip->page_table[4]; in priority_queue_cfg()
1275 return -EINVAL; in priority_queue_cfg()
1278 pg_tbl = &chip->page_table[0]; in priority_queue_cfg()
1281 return -EINVAL; in priority_queue_cfg()
1284 pubq_num = fifo->acq_pg_num - pg_tbl->hq_num - pg_tbl->lq_num - in priority_queue_cfg()
1285 pg_tbl->nq_num - pg_tbl->exq_num - pg_tbl->gapq_num; in priority_queue_cfg()
1294 struct rtw_fifo_conf *fifo = &rtwdev->fifo; in init_h2c() local
1305 h2cq_addr = fifo->rsvd_h2cq_addr << TX_PAGE_SIZE_SHIFT; in init_h2c()
1335 h2cq_free = wp >= rp ? h2cq_size - (wp - rp) : rp - wp; in init_h2c()
1339 return -EINVAL; in init_h2c()
1384 const struct rtw_chip_info *chip = rtwdev->chip; in rtw_mac_init()
1391 ret = chip->ops->mac_init(rtwdev); in rtw_mac_init()