Lines Matching +full:no +full:- +full:sdio
1 // SPDX-License-Identifier: GPL-2.0-only
3 * NXP Wireless LAN device driver: SDIO specific handling
5 * Copyright 2011-2020 NXP
17 #include "sdio.h"
528 * The device node is saved in card->plt_of_node.
534 if (!of_match_node(mwifiex_sdio_of_match_table, dev->of_node)) { in mwifiex_sdio_probe_of()
536 return -EINVAL; in mwifiex_sdio_probe_of()
543 * SDIO probe.
546 * the card structure, enables SDIO function number and initiates the
557 func->vendor, func->device, func->class, func->num); in mwifiex_sdio_probe()
559 card = devm_kzalloc(&func->dev, sizeof(*card), GFP_KERNEL); in mwifiex_sdio_probe()
561 return -ENOMEM; in mwifiex_sdio_probe()
563 init_completion(&card->fw_done); in mwifiex_sdio_probe()
565 card->func = func; in mwifiex_sdio_probe()
567 func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE; in mwifiex_sdio_probe()
569 if (id->driver_data) { in mwifiex_sdio_probe()
570 struct mwifiex_sdio_device *data = (void *)id->driver_data; in mwifiex_sdio_probe()
572 card->firmware = data->firmware; in mwifiex_sdio_probe()
573 card->firmware_sdiouart = data->firmware_sdiouart; in mwifiex_sdio_probe()
574 card->reg = data->reg; in mwifiex_sdio_probe()
575 card->max_ports = data->max_ports; in mwifiex_sdio_probe()
576 card->mp_agg_pkt_limit = data->mp_agg_pkt_limit; in mwifiex_sdio_probe()
577 card->supports_sdio_new_mode = data->supports_sdio_new_mode; in mwifiex_sdio_probe()
578 card->has_control_mask = data->has_control_mask; in mwifiex_sdio_probe()
579 card->tx_buf_size = data->tx_buf_size; in mwifiex_sdio_probe()
580 card->mp_tx_agg_buf_size = data->mp_tx_agg_buf_size; in mwifiex_sdio_probe()
581 card->mp_rx_agg_buf_size = data->mp_rx_agg_buf_size; in mwifiex_sdio_probe()
582 card->can_dump_fw = data->can_dump_fw; in mwifiex_sdio_probe()
583 card->fw_dump_enh = data->fw_dump_enh; in mwifiex_sdio_probe()
584 card->can_auto_tdls = data->can_auto_tdls; in mwifiex_sdio_probe()
585 card->can_ext_scan = data->can_ext_scan; in mwifiex_sdio_probe()
586 card->fw_ready_extra_delay = data->fw_ready_extra_delay; in mwifiex_sdio_probe()
587 card->host_mlme = data->host_mlme; in mwifiex_sdio_probe()
588 INIT_WORK(&card->work, mwifiex_sdio_work); in mwifiex_sdio_probe()
596 dev_err(&func->dev, "failed to enable function\n"); in mwifiex_sdio_probe()
601 if (func->dev.of_node) { in mwifiex_sdio_probe()
602 ret = mwifiex_sdio_probe_of(&func->dev); in mwifiex_sdio_probe()
607 ret = mwifiex_add_card(card, &card->fw_done, &sdio_ops, in mwifiex_sdio_probe()
608 MWIFIEX_SDIO, &func->dev); in mwifiex_sdio_probe()
610 dev_err(&func->dev, "add card failed\n"); in mwifiex_sdio_probe()
625 * SDIO resume.
641 if (!card || !card->adapter) { in mwifiex_sdio_resume()
646 adapter = card->adapter; in mwifiex_sdio_resume()
648 if (!test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) { in mwifiex_sdio_resume()
654 clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_sdio_resume()
665 /* Write data into SDIO card register. Caller claims SDIO device. */
669 int ret = -1; in mwifiex_write_reg_locked()
675 /* This function writes data into SDIO card register.
680 struct sdio_mmc_card *card = adapter->card; in mwifiex_write_reg()
683 sdio_claim_host(card->func); in mwifiex_write_reg()
684 ret = mwifiex_write_reg_locked(card->func, reg, data); in mwifiex_write_reg()
685 sdio_release_host(card->func); in mwifiex_write_reg()
690 /* This function reads data from SDIO card register.
695 struct sdio_mmc_card *card = adapter->card; in mwifiex_read_reg()
696 int ret = -1; in mwifiex_read_reg()
699 sdio_claim_host(card->func); in mwifiex_read_reg()
700 val = sdio_readb(card->func, reg, &ret); in mwifiex_read_reg()
701 sdio_release_host(card->func); in mwifiex_read_reg()
708 /* This function writes multiple data into SDIO card memory.
716 struct sdio_mmc_card *card = adapter->card; in mwifiex_write_data_sync()
727 if (test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) { in mwifiex_write_data_sync()
730 return -1; in mwifiex_write_data_sync()
733 sdio_claim_host(card->func); in mwifiex_write_data_sync()
735 ret = sdio_writesb(card->func, ioport, buffer, blk_cnt * blk_size); in mwifiex_write_data_sync()
737 sdio_release_host(card->func); in mwifiex_write_data_sync()
742 /* This function reads multiple data from SDIO card memory.
747 struct sdio_mmc_card *card = adapter->card; in mwifiex_read_data_sync()
757 sdio_claim_host(card->func); in mwifiex_read_data_sync()
759 ret = sdio_readsb(card->func, buffer, ioport, blk_cnt * blk_size); in mwifiex_read_data_sync()
762 sdio_release_host(card->func); in mwifiex_read_data_sync()
772 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_read_fw_status()
773 const struct mwifiex_sdio_card_reg *reg = card->reg; in mwifiex_sdio_read_fw_status()
776 if (mwifiex_read_reg(adapter, reg->status_reg_0, &fws0)) in mwifiex_sdio_read_fw_status()
777 return -1; in mwifiex_sdio_read_fw_status()
779 if (mwifiex_read_reg(adapter, reg->status_reg_1, &fws1)) in mwifiex_sdio_read_fw_status()
780 return -1; in mwifiex_sdio_read_fw_status()
791 struct sdio_mmc_card *card = adapter->card; in mwifiex_check_fw_status()
806 ret = -1; in mwifiex_check_fw_status()
809 if (card->fw_ready_extra_delay && in mwifiex_check_fw_status()
825 struct sdio_mmc_card *card = adapter->card; in mwifiex_check_winner_status()
827 if (mwifiex_read_reg(adapter, card->reg->status_reg_0, &winner)) in mwifiex_check_winner_status()
828 return -1; in mwifiex_check_winner_status()
831 adapter->winner = 0; in mwifiex_check_winner_status()
833 adapter->winner = 1; in mwifiex_check_winner_status()
839 * SDIO remove.
856 wait_for_completion(&card->fw_done); in mwifiex_sdio_remove()
858 adapter = card->adapter; in mwifiex_sdio_remove()
859 if (!adapter || !adapter->priv_num) in mwifiex_sdio_remove()
862 mwifiex_dbg(adapter, INFO, "info: SDIO func num=%d\n", func->num); in mwifiex_sdio_remove()
866 !adapter->mfg_mode) { in mwifiex_sdio_remove()
878 * SDIO suspend.
901 return -ENOSYS; in mwifiex_sdio_suspend()
911 wait_for_completion(&card->fw_done); in mwifiex_sdio_suspend()
913 adapter = card->adapter; in mwifiex_sdio_suspend()
919 if (!adapter->is_up) in mwifiex_sdio_suspend()
920 return -EBUSY; in mwifiex_sdio_suspend()
928 clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags); in mwifiex_sdio_suspend()
930 return -EFAULT; in mwifiex_sdio_suspend()
938 set_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_sdio_suspend()
939 clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags); in mwifiex_sdio_suspend()
951 &card->work_flags)) in mwifiex_sdio_coredump()
952 schedule_work(&card->work); in mwifiex_sdio_coredump()
980 MODULE_DEVICE_TABLE(sdio, mwifiex_ids);
1028 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_dnld_fw()
1031 sdio_claim_host(card->func); in mwifiex_sdio_dnld_fw()
1033 sdio_release_host(card->func); in mwifiex_sdio_dnld_fw()
1040 * chipsets supporting SDIO new mode eg SD8897.
1045 struct sdio_mmc_card *card = adapter->card; in mwifiex_init_sdio_new_mode()
1047 adapter->ioport = MEM_PORT; in mwifiex_init_sdio_new_mode()
1049 /* enable sdio new mode */ in mwifiex_init_sdio_new_mode()
1050 if (mwifiex_read_reg(adapter, card->reg->card_cfg_2_1_reg, ®)) in mwifiex_init_sdio_new_mode()
1051 return -1; in mwifiex_init_sdio_new_mode()
1052 if (mwifiex_write_reg(adapter, card->reg->card_cfg_2_1_reg, in mwifiex_init_sdio_new_mode()
1054 return -1; in mwifiex_init_sdio_new_mode()
1057 if (mwifiex_read_reg(adapter, card->reg->cmd_cfg_0, ®)) in mwifiex_init_sdio_new_mode()
1058 return -1; in mwifiex_init_sdio_new_mode()
1059 if (mwifiex_write_reg(adapter, card->reg->cmd_cfg_0, in mwifiex_init_sdio_new_mode()
1061 return -1; in mwifiex_init_sdio_new_mode()
1066 if (mwifiex_read_reg(adapter, card->reg->cmd_cfg_1, ®)) in mwifiex_init_sdio_new_mode()
1067 return -1; in mwifiex_init_sdio_new_mode()
1068 if (mwifiex_write_reg(adapter, card->reg->cmd_cfg_1, in mwifiex_init_sdio_new_mode()
1070 return -1; in mwifiex_init_sdio_new_mode()
1077 * The following operations are performed -
1078 * - Read the IO ports (0, 1 and 2)
1079 * - Set host interrupt Reset-To-Read to clear
1080 * - Set auto re-enable interrupt
1085 struct sdio_mmc_card *card = adapter->card; in mwifiex_init_sdio_ioport()
1087 adapter->ioport = 0; in mwifiex_init_sdio_ioport()
1089 if (card->supports_sdio_new_mode) { in mwifiex_init_sdio_ioport()
1091 return -1; in mwifiex_init_sdio_ioport()
1096 if (!mwifiex_read_reg(adapter, card->reg->io_port_0_reg, ®)) in mwifiex_init_sdio_ioport()
1097 adapter->ioport |= (reg & 0xff); in mwifiex_init_sdio_ioport()
1099 return -1; in mwifiex_init_sdio_ioport()
1101 if (!mwifiex_read_reg(adapter, card->reg->io_port_1_reg, ®)) in mwifiex_init_sdio_ioport()
1102 adapter->ioport |= ((reg & 0xff) << 8); in mwifiex_init_sdio_ioport()
1104 return -1; in mwifiex_init_sdio_ioport()
1106 if (!mwifiex_read_reg(adapter, card->reg->io_port_2_reg, ®)) in mwifiex_init_sdio_ioport()
1107 adapter->ioport |= ((reg & 0xff) << 16); in mwifiex_init_sdio_ioport()
1109 return -1; in mwifiex_init_sdio_ioport()
1112 "info: SDIO FUNC1 IO port: %#x\n", adapter->ioport); in mwifiex_init_sdio_ioport()
1115 if (mwifiex_read_reg(adapter, card->reg->host_int_rsr_reg, ®)) in mwifiex_init_sdio_ioport()
1116 return -1; in mwifiex_init_sdio_ioport()
1117 if (mwifiex_write_reg(adapter, card->reg->host_int_rsr_reg, in mwifiex_init_sdio_ioport()
1118 reg | card->reg->sdio_int_mask)) in mwifiex_init_sdio_ioport()
1119 return -1; in mwifiex_init_sdio_ioport()
1122 if (mwifiex_read_reg(adapter, card->reg->card_misc_cfg_reg, ®)) in mwifiex_init_sdio_ioport()
1123 return -1; in mwifiex_init_sdio_ioport()
1124 if (mwifiex_write_reg(adapter, card->reg->card_misc_cfg_reg, in mwifiex_init_sdio_ioport()
1126 return -1; in mwifiex_init_sdio_ioport()
1151 ret = -1; in mwifiex_write_data_to_card()
1155 } while (ret == -1); in mwifiex_write_data_to_card()
1170 struct sdio_mmc_card *card = adapter->card; in mwifiex_get_rd_port()
1171 const struct mwifiex_sdio_card_reg *reg = card->reg; in mwifiex_get_rd_port()
1172 u32 rd_bitmap = card->mp_rd_bitmap; in mwifiex_get_rd_port()
1177 if (card->supports_sdio_new_mode) { in mwifiex_get_rd_port()
1178 if (!(rd_bitmap & reg->data_port_mask)) in mwifiex_get_rd_port()
1179 return -1; in mwifiex_get_rd_port()
1181 if (!(rd_bitmap & (CTRL_PORT_MASK | reg->data_port_mask))) in mwifiex_get_rd_port()
1182 return -1; in mwifiex_get_rd_port()
1185 if ((card->has_control_mask) && in mwifiex_get_rd_port()
1186 (card->mp_rd_bitmap & CTRL_PORT_MASK)) { in mwifiex_get_rd_port()
1187 card->mp_rd_bitmap &= (u32) (~CTRL_PORT_MASK); in mwifiex_get_rd_port()
1191 *port, card->mp_rd_bitmap); in mwifiex_get_rd_port()
1195 if (!(card->mp_rd_bitmap & (1 << card->curr_rd_port))) in mwifiex_get_rd_port()
1196 return -1; in mwifiex_get_rd_port()
1198 /* We are now handling the SDIO data ports */ in mwifiex_get_rd_port()
1199 card->mp_rd_bitmap &= (u32)(~(1 << card->curr_rd_port)); in mwifiex_get_rd_port()
1200 *port = card->curr_rd_port; in mwifiex_get_rd_port()
1202 if (++card->curr_rd_port == card->max_ports) in mwifiex_get_rd_port()
1203 card->curr_rd_port = reg->start_rd_port; in mwifiex_get_rd_port()
1206 "data: port=%d mp_rd_bitmap=0x%08x -> 0x%08x\n", in mwifiex_get_rd_port()
1207 *port, rd_bitmap, card->mp_rd_bitmap); in mwifiex_get_rd_port()
1221 struct sdio_mmc_card *card = adapter->card; in mwifiex_get_wr_port_data()
1222 const struct mwifiex_sdio_card_reg *reg = card->reg; in mwifiex_get_wr_port_data()
1223 u32 wr_bitmap = card->mp_wr_bitmap; in mwifiex_get_wr_port_data()
1228 if (!(wr_bitmap & card->mp_data_port_mask)) { in mwifiex_get_wr_port_data()
1229 adapter->data_sent = true; in mwifiex_get_wr_port_data()
1230 return -EBUSY; in mwifiex_get_wr_port_data()
1233 if (card->mp_wr_bitmap & (1 << card->curr_wr_port)) { in mwifiex_get_wr_port_data()
1234 card->mp_wr_bitmap &= (u32) (~(1 << card->curr_wr_port)); in mwifiex_get_wr_port_data()
1235 *port = card->curr_wr_port; in mwifiex_get_wr_port_data()
1236 if (++card->curr_wr_port == card->mp_end_port) in mwifiex_get_wr_port_data()
1237 card->curr_wr_port = reg->start_wr_port; in mwifiex_get_wr_port_data()
1239 adapter->data_sent = true; in mwifiex_get_wr_port_data()
1240 return -EBUSY; in mwifiex_get_wr_port_data()
1243 if ((card->has_control_mask) && (*port == CTRL_PORT)) { in mwifiex_get_wr_port_data()
1245 "invalid data port=%d cur port=%d mp_wr_bitmap=0x%08x -> 0x%08x\n", in mwifiex_get_wr_port_data()
1246 *port, card->curr_wr_port, wr_bitmap, in mwifiex_get_wr_port_data()
1247 card->mp_wr_bitmap); in mwifiex_get_wr_port_data()
1248 return -1; in mwifiex_get_wr_port_data()
1252 "data: port=%d mp_wr_bitmap=0x%08x -> 0x%08x\n", in mwifiex_get_wr_port_data()
1253 *port, wr_bitmap, card->mp_wr_bitmap); in mwifiex_get_wr_port_data()
1264 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_poll_card_status()
1269 if (mwifiex_read_reg(adapter, card->reg->poll_reg, &cs)) in mwifiex_sdio_poll_card_status()
1280 return -1; in mwifiex_sdio_poll_card_status()
1291 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_disable_host_int()
1292 struct sdio_func *func = card->func; in mwifiex_sdio_disable_host_int()
1295 mwifiex_write_reg_locked(func, card->reg->host_int_mask_reg, 0); in mwifiex_sdio_disable_host_int()
1305 struct sdio_mmc_card *card = adapter->card; in mwifiex_interrupt_status()
1309 if (mwifiex_read_data_sync(adapter, card->mp_regs, in mwifiex_interrupt_status()
1310 card->reg->max_mp_regs, in mwifiex_interrupt_status()
1316 sdio_ireg = card->mp_regs[card->reg->host_int_status_reg]; in mwifiex_interrupt_status()
1320 * For SDIO new mode CMD port interrupts in mwifiex_interrupt_status()
1327 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_interrupt_status()
1328 adapter->int_status |= sdio_ireg; in mwifiex_interrupt_status()
1329 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_interrupt_status()
1334 * SDIO interrupt handler.
1346 if (!card || !card->adapter) { in mwifiex_sdio_interrupt()
1348 func, card, card ? card->adapter : NULL); in mwifiex_sdio_interrupt()
1351 adapter = card->adapter; in mwifiex_sdio_interrupt()
1353 if (!adapter->pps_uapsd_mode && adapter->ps_state == PS_STATE_SLEEP) in mwifiex_sdio_interrupt()
1354 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_sdio_interrupt()
1368 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_enable_host_int()
1369 struct sdio_func *func = card->func; in mwifiex_sdio_enable_host_int()
1374 /* Request the SDIO IRQ */ in mwifiex_sdio_enable_host_int()
1383 ret = mwifiex_write_reg_locked(func, card->reg->host_int_mask_reg, in mwifiex_sdio_enable_host_int()
1384 card->reg->host_int_enable); in mwifiex_sdio_enable_host_int()
1409 return -1; in mwifiex_sdio_card_to_host()
1418 return -1; in mwifiex_sdio_card_to_host()
1426 return -1; in mwifiex_sdio_card_to_host()
1444 struct sdio_mmc_card *card = adapter->card; in mwifiex_prog_fw_w_helper()
1445 const struct mwifiex_sdio_card_reg *reg = card->reg; in mwifiex_prog_fw_w_helper()
1447 u8 *firmware = fw->fw_buf; in mwifiex_prog_fw_w_helper()
1448 u32 firmware_len = fw->fw_len; in mwifiex_prog_fw_w_helper()
1459 return -1; in mwifiex_prog_fw_w_helper()
1466 /* Assume that the allocated buffer is 8-byte aligned */ in mwifiex_prog_fw_w_helper()
1469 return -ENOMEM; in mwifiex_prog_fw_w_helper()
1471 sdio_claim_host(card->func); in mwifiex_prog_fw_w_helper()
1491 ret = mwifiex_read_reg(adapter, reg->base_0_reg, in mwifiex_prog_fw_w_helper()
1500 ret = mwifiex_read_reg(adapter, reg->base_1_reg, in mwifiex_prog_fw_w_helper()
1523 ret = -1; in mwifiex_prog_fw_w_helper()
1535 ret = -1; in mwifiex_prog_fw_w_helper()
1547 /* Set blocksize to transfer - checking for last in mwifiex_prog_fw_w_helper()
1549 if (firmware_len - offset < txlen) in mwifiex_prog_fw_w_helper()
1550 txlen = firmware_len - offset; in mwifiex_prog_fw_w_helper()
1552 tx_blocks = (txlen + MWIFIEX_SDIO_BLOCK_SIZE - 1) in mwifiex_prog_fw_w_helper()
1561 adapter->ioport); in mwifiex_prog_fw_w_helper()
1570 ret = -1; in mwifiex_prog_fw_w_helper()
1582 sdio_release_host(card->func); in mwifiex_prog_fw_w_helper()
1588 * This function decodes sdio aggregation pkt.
1602 data = skb->data; in mwifiex_deaggr_sdio_pkt()
1603 total_pkt_len = skb->len; in mwifiex_deaggr_sdio_pkt()
1605 while (total_pkt_len >= (SDIO_HEADER_OFFSET + adapter->intf_hdr_len)) { in mwifiex_deaggr_sdio_pkt()
1606 if (total_pkt_len < adapter->sdio_rx_block_size) in mwifiex_deaggr_sdio_pkt()
1609 blk_size = adapter->sdio_rx_block_size * blk_num; in mwifiex_deaggr_sdio_pkt()
1631 memcpy(skb_deaggr->data, data + SDIO_HEADER_OFFSET, pkt_len); in mwifiex_deaggr_sdio_pkt()
1632 skb_pull(skb_deaggr, adapter->intf_hdr_len); in mwifiex_deaggr_sdio_pkt()
1636 total_pkt_len -= blk_size; in mwifiex_deaggr_sdio_pkt()
1654 pkt_len = get_unaligned_le16(skb->data); in mwifiex_decode_rx_packet()
1658 skb_pull(skb, adapter->intf_hdr_len); in mwifiex_decode_rx_packet()
1664 "info: --- Rx: Aggr Data packet ---\n"); in mwifiex_decode_rx_packet()
1666 rx_info->buf_type = MWIFIEX_TYPE_AGGR_DATA; in mwifiex_decode_rx_packet()
1667 if (adapter->rx_work_enabled) { in mwifiex_decode_rx_packet()
1668 skb_queue_tail(&adapter->rx_data_q, skb); in mwifiex_decode_rx_packet()
1669 atomic_inc(&adapter->rx_pending); in mwifiex_decode_rx_packet()
1670 adapter->data_received = true; in mwifiex_decode_rx_packet()
1679 "info: --- Rx: Data packet ---\n"); in mwifiex_decode_rx_packet()
1680 if (adapter->rx_work_enabled) { in mwifiex_decode_rx_packet()
1681 skb_queue_tail(&adapter->rx_data_q, skb); in mwifiex_decode_rx_packet()
1682 adapter->data_received = true; in mwifiex_decode_rx_packet()
1683 atomic_inc(&adapter->rx_pending); in mwifiex_decode_rx_packet()
1691 "info: --- Rx: Cmd Response ---\n"); in mwifiex_decode_rx_packet()
1693 if (!adapter->curr_cmd) { in mwifiex_decode_rx_packet()
1694 cmd_buf = adapter->upld_buf; in mwifiex_decode_rx_packet()
1696 if (adapter->ps_state == PS_STATE_SLEEP_CFM) in mwifiex_decode_rx_packet()
1698 skb->data, in mwifiex_decode_rx_packet()
1699 skb->len); in mwifiex_decode_rx_packet()
1701 memcpy(cmd_buf, skb->data, in mwifiex_decode_rx_packet()
1703 skb->len)); in mwifiex_decode_rx_packet()
1707 adapter->cmd_resp_received = true; in mwifiex_decode_rx_packet()
1708 adapter->curr_cmd->resp_skb = skb; in mwifiex_decode_rx_packet()
1714 "info: --- Rx: Event ---\n"); in mwifiex_decode_rx_packet()
1715 adapter->event_cause = get_unaligned_le32(skb->data); in mwifiex_decode_rx_packet()
1717 if ((skb->len > 0) && (skb->len < MAX_EVENT_SIZE)) in mwifiex_decode_rx_packet()
1718 memcpy(adapter->event_body, in mwifiex_decode_rx_packet()
1719 skb->data + MWIFIEX_EVENT_HEADER_LEN, in mwifiex_decode_rx_packet()
1720 skb->len); in mwifiex_decode_rx_packet()
1722 /* event cause has been saved to adapter->event_cause */ in mwifiex_decode_rx_packet()
1723 adapter->event_received = true; in mwifiex_decode_rx_packet()
1724 adapter->event_skb = skb; in mwifiex_decode_rx_packet()
1750 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_card_to_host_mp_aggr()
1760 if ((card->has_control_mask) && (port == CTRL_PORT)) { in mwifiex_sdio_card_to_host_mp_aggr()
1763 "info: %s: no aggregation for cmd\t" in mwifiex_sdio_card_to_host_mp_aggr()
1770 if (!card->mpa_rx.enabled) { in mwifiex_sdio_card_to_host_mp_aggr()
1779 if ((!card->has_control_mask && (card->mp_rd_bitmap & in mwifiex_sdio_card_to_host_mp_aggr()
1780 card->reg->data_port_mask)) || in mwifiex_sdio_card_to_host_mp_aggr()
1781 (card->has_control_mask && (card->mp_rd_bitmap & in mwifiex_sdio_card_to_host_mp_aggr()
1791 /* No room in Aggr buf, do rx aggr now */ in mwifiex_sdio_card_to_host_mp_aggr()
1801 /* No more data RX pending */ in mwifiex_sdio_card_to_host_mp_aggr()
1810 /* No room in Aggr buf, do rx aggr now */ in mwifiex_sdio_card_to_host_mp_aggr()
1828 /* No more pkts allowed in Aggr buf, rx it */ in mwifiex_sdio_card_to_host_mp_aggr()
1837 card->mpa_rx.pkt_cnt); in mwifiex_sdio_card_to_host_mp_aggr()
1839 if (card->supports_sdio_new_mode) { in mwifiex_sdio_card_to_host_mp_aggr()
1843 for (i = 0, port_count = 0; i < card->max_ports; i++) in mwifiex_sdio_card_to_host_mp_aggr()
1844 if (card->mpa_rx.ports & BIT(i)) in mwifiex_sdio_card_to_host_mp_aggr()
1848 * port_count -1", so decrease the count by 1 in mwifiex_sdio_card_to_host_mp_aggr()
1850 port_count--; in mwifiex_sdio_card_to_host_mp_aggr()
1851 mport = (adapter->ioport | SDIO_MPA_ADDR_BASE | in mwifiex_sdio_card_to_host_mp_aggr()
1852 (port_count << 8)) + card->mpa_rx.start_port; in mwifiex_sdio_card_to_host_mp_aggr()
1854 mport = (adapter->ioport | SDIO_MPA_ADDR_BASE | in mwifiex_sdio_card_to_host_mp_aggr()
1855 (card->mpa_rx.ports << 4)) + in mwifiex_sdio_card_to_host_mp_aggr()
1856 card->mpa_rx.start_port; in mwifiex_sdio_card_to_host_mp_aggr()
1859 if (card->mpa_rx.pkt_cnt == 1) in mwifiex_sdio_card_to_host_mp_aggr()
1860 mport = adapter->ioport + card->mpa_rx.start_port; in mwifiex_sdio_card_to_host_mp_aggr()
1862 if (mwifiex_read_data_sync(adapter, card->mpa_rx.buf, in mwifiex_sdio_card_to_host_mp_aggr()
1863 card->mpa_rx.buf_len, mport, 1)) in mwifiex_sdio_card_to_host_mp_aggr()
1866 curr_ptr = card->mpa_rx.buf; in mwifiex_sdio_card_to_host_mp_aggr()
1868 for (pind = 0; pind < card->mpa_rx.pkt_cnt; pind++) { in mwifiex_sdio_card_to_host_mp_aggr()
1869 u32 *len_arr = card->mpa_rx.len_arr; in mwifiex_sdio_card_to_host_mp_aggr()
1890 adapter->sdio_rx_aggr_enable)) && in mwifiex_sdio_card_to_host_mp_aggr()
1893 memcpy(skb_deaggr->data, curr_ptr, pkt_len); in mwifiex_sdio_card_to_host_mp_aggr()
1897 /* Process de-aggr packet */ in mwifiex_sdio_card_to_host_mp_aggr()
1905 adapter->sdio_rx_aggr_enable, in mwifiex_sdio_card_to_host_mp_aggr()
1925 card->mpa_rx.buf, rx_len, in mwifiex_sdio_card_to_host_mp_aggr()
1926 adapter->ioport + port)) in mwifiex_sdio_card_to_host_mp_aggr()
1934 skb->data, skb->len, in mwifiex_sdio_card_to_host_mp_aggr()
1935 adapter->ioport + port)) in mwifiex_sdio_card_to_host_mp_aggr()
1937 if (!adapter->sdio_rx_aggr_enable && in mwifiex_sdio_card_to_host_mp_aggr()
1940 "current SDIO RX Aggr not enabled\n", in mwifiex_sdio_card_to_host_mp_aggr()
1964 return -1; in mwifiex_sdio_card_to_host_mp_aggr()
1970 * The following interrupts are checked and handled by this function -
1971 * - Data sent
1972 * - Command sent
1973 * - Packets received
1977 * should be done manually, and for every SDIO interrupt.
1984 struct sdio_mmc_card *card = adapter->card; in mwifiex_process_int_status()
1985 const struct mwifiex_sdio_card_reg *reg = card->reg; in mwifiex_process_int_status()
1997 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_process_int_status()
1998 sdio_ireg = adapter->int_status; in mwifiex_process_int_status()
1999 adapter->int_status = 0; in mwifiex_process_int_status()
2000 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_process_int_status()
2005 /* Following interrupt is only for SDIO new mode */ in mwifiex_process_int_status()
2006 if (sdio_ireg & DN_LD_CMD_PORT_HOST_INT_STATUS && adapter->cmd_sent) in mwifiex_process_int_status()
2007 adapter->cmd_sent = false; in mwifiex_process_int_status()
2009 /* Following interrupt is only for SDIO new mode */ in mwifiex_process_int_status()
2014 rx_len = card->mp_regs[reg->cmd_rd_len_1] << 8; in mwifiex_process_int_status()
2015 rx_len |= (u16)card->mp_regs[reg->cmd_rd_len_0]; in mwifiex_process_int_status()
2017 if (rx_len <= adapter->intf_hdr_len || in mwifiex_process_int_status()
2020 return -1; in mwifiex_process_int_status()
2026 return -1; in mwifiex_process_int_status()
2030 if (mwifiex_sdio_card_to_host(adapter, &pkt_type, skb->data, in mwifiex_process_int_status()
2031 skb->len, adapter->ioport | in mwifiex_process_int_status()
2049 bitmap = (u32) card->mp_regs[reg->wr_bitmap_l]; in mwifiex_process_int_status()
2050 bitmap |= ((u32) card->mp_regs[reg->wr_bitmap_u]) << 8; in mwifiex_process_int_status()
2051 if (card->supports_sdio_new_mode) { in mwifiex_process_int_status()
2053 ((u32) card->mp_regs[reg->wr_bitmap_1l]) << 16; in mwifiex_process_int_status()
2055 ((u32) card->mp_regs[reg->wr_bitmap_1u]) << 24; in mwifiex_process_int_status()
2057 card->mp_wr_bitmap = bitmap; in mwifiex_process_int_status()
2061 card->mp_wr_bitmap); in mwifiex_process_int_status()
2062 if (adapter->data_sent && in mwifiex_process_int_status()
2063 (card->mp_wr_bitmap & card->mp_data_port_mask)) { in mwifiex_process_int_status()
2065 "info: <--- Tx DONE Interrupt --->\n"); in mwifiex_process_int_status()
2066 adapter->data_sent = false; in mwifiex_process_int_status()
2071 updated is command port only, cmd_sent should be done for any SDIO in mwifiex_process_int_status()
2073 if (card->has_control_mask && adapter->cmd_sent) { in mwifiex_process_int_status()
2076 card->mp_wr_bitmap |= in mwifiex_process_int_status()
2077 (u32) card->mp_regs[reg->wr_bitmap_l] & CTRL_PORT_MASK; in mwifiex_process_int_status()
2078 if (card->mp_wr_bitmap & CTRL_PORT_MASK) in mwifiex_process_int_status()
2079 adapter->cmd_sent = false; in mwifiex_process_int_status()
2083 adapter->cmd_sent, adapter->data_sent); in mwifiex_process_int_status()
2085 bitmap = (u32) card->mp_regs[reg->rd_bitmap_l]; in mwifiex_process_int_status()
2086 bitmap |= ((u32) card->mp_regs[reg->rd_bitmap_u]) << 8; in mwifiex_process_int_status()
2087 if (card->supports_sdio_new_mode) { in mwifiex_process_int_status()
2089 ((u32) card->mp_regs[reg->rd_bitmap_1l]) << 16; in mwifiex_process_int_status()
2091 ((u32) card->mp_regs[reg->rd_bitmap_1u]) << 24; in mwifiex_process_int_status()
2093 card->mp_rd_bitmap = bitmap; in mwifiex_process_int_status()
2096 card->mp_rd_bitmap); in mwifiex_process_int_status()
2102 "info: no more rd_port available\n"); in mwifiex_process_int_status()
2105 len_reg_l = reg->rd_len_p0_l + (port << 1); in mwifiex_process_int_status()
2106 len_reg_u = reg->rd_len_p0_u + (port << 1); in mwifiex_process_int_status()
2107 rx_len = ((u16) card->mp_regs[len_reg_u]) << 8; in mwifiex_process_int_status()
2108 rx_len |= (u16) card->mp_regs[len_reg_l]; in mwifiex_process_int_status()
2113 (rx_len + MWIFIEX_SDIO_BLOCK_SIZE - in mwifiex_process_int_status()
2115 if (rx_len <= adapter->intf_hdr_len || in mwifiex_process_int_status()
2116 (card->mpa_rx.enabled && in mwifiex_process_int_status()
2118 card->mpa_rx.buf_size))) { in mwifiex_process_int_status()
2122 return -1; in mwifiex_process_int_status()
2162 return -1; in mwifiex_process_int_status()
2171 * aggregation buffer are pre-copied first before new packets are added.
2183 struct sdio_mmc_card *card = adapter->card; in mwifiex_host_to_card_mp_aggr()
2192 if (!card->mpa_tx.enabled || in mwifiex_host_to_card_mp_aggr()
2193 (card->has_control_mask && (port == CTRL_PORT)) || in mwifiex_host_to_card_mp_aggr()
2194 (card->supports_sdio_new_mode && (port == CMD_PORT_SLCT))) { in mwifiex_host_to_card_mp_aggr()
2213 if (!(card->mp_wr_bitmap & in mwifiex_host_to_card_mp_aggr()
2214 (1 << card->curr_wr_port)) || in mwifiex_host_to_card_mp_aggr()
2219 /* No room in Aggr buf, send it */ in mwifiex_host_to_card_mp_aggr()
2222 if (!(card->mp_wr_bitmap & in mwifiex_host_to_card_mp_aggr()
2223 (1 << card->curr_wr_port))) in mwifiex_host_to_card_mp_aggr()
2230 (card->mp_wr_bitmap & (1 << card->curr_wr_port))) in mwifiex_host_to_card_mp_aggr()
2248 /* No room in Aggr buf, send it */ in mwifiex_host_to_card_mp_aggr()
2263 /* No more pkts allowed in Aggr buf, send it */ in mwifiex_host_to_card_mp_aggr()
2270 __func__, card->mpa_tx.start_port, in mwifiex_host_to_card_mp_aggr()
2271 card->mpa_tx.ports); in mwifiex_host_to_card_mp_aggr()
2272 if (card->supports_sdio_new_mode) { in mwifiex_host_to_card_mp_aggr()
2276 for (i = 0, port_count = 0; i < card->max_ports; i++) in mwifiex_host_to_card_mp_aggr()
2277 if (card->mpa_tx.ports & BIT(i)) in mwifiex_host_to_card_mp_aggr()
2281 * port_count -1", so decrease the count by 1 in mwifiex_host_to_card_mp_aggr()
2283 port_count--; in mwifiex_host_to_card_mp_aggr()
2284 mport = (adapter->ioport | SDIO_MPA_ADDR_BASE | in mwifiex_host_to_card_mp_aggr()
2285 (port_count << 8)) + card->mpa_tx.start_port; in mwifiex_host_to_card_mp_aggr()
2287 mport = (adapter->ioport | SDIO_MPA_ADDR_BASE | in mwifiex_host_to_card_mp_aggr()
2288 (card->mpa_tx.ports << 4)) + in mwifiex_host_to_card_mp_aggr()
2289 card->mpa_tx.start_port; in mwifiex_host_to_card_mp_aggr()
2292 if (card->mpa_tx.pkt_cnt == 1) in mwifiex_host_to_card_mp_aggr()
2293 mport = adapter->ioport + card->mpa_tx.start_port; in mwifiex_host_to_card_mp_aggr()
2295 ret = mwifiex_write_data_to_card(adapter, card->mpa_tx.buf, in mwifiex_host_to_card_mp_aggr()
2296 card->mpa_tx.buf_len, mport); in mwifiex_host_to_card_mp_aggr()
2299 index = adapter->dbg.last_sdio_mp_index; in mwifiex_host_to_card_mp_aggr()
2301 adapter->dbg.last_sdio_mp_index = index; in mwifiex_host_to_card_mp_aggr()
2302 adapter->dbg.last_mp_wr_ports[index] = mport; in mwifiex_host_to_card_mp_aggr()
2303 adapter->dbg.last_mp_wr_bitmap[index] = card->mp_wr_bitmap; in mwifiex_host_to_card_mp_aggr()
2304 adapter->dbg.last_mp_wr_len[index] = card->mpa_tx.buf_len; in mwifiex_host_to_card_mp_aggr()
2305 adapter->dbg.last_mp_curr_wr_port[index] = card->curr_wr_port; in mwifiex_host_to_card_mp_aggr()
2316 adapter->ioport + port); in mwifiex_host_to_card_mp_aggr()
2335 * This function adds the SDIO specific header to the front of the buffer
2343 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_host_to_card()
2348 u8 *payload = (u8 *)skb->data; in mwifiex_sdio_host_to_card()
2349 u32 pkt_len = skb->len; in mwifiex_sdio_host_to_card()
2353 buf_block_len = (pkt_len + blk_size - 1) / blk_size; in mwifiex_sdio_host_to_card()
2359 * This is SDIO specific header in mwifiex_sdio_host_to_card()
2368 "%s: no wr_port available\n", in mwifiex_sdio_host_to_card()
2373 adapter->cmd_sent = true; in mwifiex_sdio_host_to_card()
2376 if (pkt_len <= adapter->intf_hdr_len || in mwifiex_sdio_host_to_card()
2382 if (card->supports_sdio_new_mode) in mwifiex_sdio_host_to_card()
2391 port, tx_param->next_pkt_len in mwifiex_sdio_host_to_card()
2399 adapter->cmd_sent = false; in mwifiex_sdio_host_to_card()
2401 adapter->data_sent = false; in mwifiex_sdio_host_to_card()
2403 card->curr_wr_port = port; in mwifiex_sdio_host_to_card()
2404 card->mp_wr_bitmap |= (u32)(1 << card->curr_wr_port); in mwifiex_sdio_host_to_card()
2408 if (!(card->mp_wr_bitmap & (1 << card->curr_wr_port))) in mwifiex_sdio_host_to_card()
2409 adapter->data_sent = true; in mwifiex_sdio_host_to_card()
2411 adapter->data_sent = false; in mwifiex_sdio_host_to_card()
2424 struct sdio_mmc_card *card = adapter->card; in mwifiex_alloc_sdio_mpa_buffers()
2428 card->mpa_tx.buf = kzalloc(mpa_tx_buf_size, GFP_KERNEL); in mwifiex_alloc_sdio_mpa_buffers()
2429 if (!card->mpa_tx.buf) { in mwifiex_alloc_sdio_mpa_buffers()
2430 ret = -1; in mwifiex_alloc_sdio_mpa_buffers()
2434 card->mpa_tx.buf_size = mpa_tx_buf_size; in mwifiex_alloc_sdio_mpa_buffers()
2438 card->mpa_rx.buf = kzalloc(rx_buf_size, GFP_KERNEL); in mwifiex_alloc_sdio_mpa_buffers()
2439 if (!card->mpa_rx.buf) { in mwifiex_alloc_sdio_mpa_buffers()
2440 ret = -1; in mwifiex_alloc_sdio_mpa_buffers()
2444 card->mpa_rx.buf_size = rx_buf_size; in mwifiex_alloc_sdio_mpa_buffers()
2448 kfree(card->mpa_tx.buf); in mwifiex_alloc_sdio_mpa_buffers()
2449 kfree(card->mpa_rx.buf); in mwifiex_alloc_sdio_mpa_buffers()
2450 card->mpa_tx.buf_size = 0; in mwifiex_alloc_sdio_mpa_buffers()
2451 card->mpa_rx.buf_size = 0; in mwifiex_alloc_sdio_mpa_buffers()
2452 card->mpa_tx.buf = NULL; in mwifiex_alloc_sdio_mpa_buffers()
2453 card->mpa_rx.buf = NULL; in mwifiex_alloc_sdio_mpa_buffers()
2460 * This function unregisters the SDIO device.
2462 * The SDIO IRQ is released, the function is disabled and driver
2468 struct sdio_mmc_card *card = adapter->card; in mwifiex_unregister_dev()
2470 if (adapter->card) { in mwifiex_unregister_dev()
2471 card->adapter = NULL; in mwifiex_unregister_dev()
2472 sdio_claim_host(card->func); in mwifiex_unregister_dev()
2473 sdio_disable_func(card->func); in mwifiex_unregister_dev()
2474 sdio_release_host(card->func); in mwifiex_unregister_dev()
2479 * This function registers the SDIO device.
2481 * SDIO IRQ is claimed, block size is set and driver data is initialized.
2486 struct sdio_mmc_card *card = adapter->card; in mwifiex_register_dev()
2487 struct sdio_func *func = card->func; in mwifiex_register_dev()
2488 const char *firmware = card->firmware; in mwifiex_register_dev()
2491 card->adapter = adapter; in mwifiex_register_dev()
2492 adapter->tx_buf_size = card->tx_buf_size; in mwifiex_register_dev()
2497 ret = sdio_set_block_size(card->func, MWIFIEX_SDIO_BLOCK_SIZE); in mwifiex_register_dev()
2501 "cannot set SDIO block size\n"); in mwifiex_register_dev()
2508 if (card->firmware_sdiouart) { in mwifiex_register_dev()
2511 mwifiex_read_reg(adapter, card->reg->host_strap_reg, &val); in mwifiex_register_dev()
2512 if ((val & card->reg->host_strap_mask) == card->reg->host_strap_value) in mwifiex_register_dev()
2513 firmware = card->firmware_sdiouart; in mwifiex_register_dev()
2515 strcpy(adapter->fw_name, firmware); in mwifiex_register_dev()
2517 if (card->fw_dump_enh) { in mwifiex_register_dev()
2518 adapter->mem_type_mapping_tbl = generic_mem_type_map; in mwifiex_register_dev()
2519 adapter->num_mem_types = 1; in mwifiex_register_dev()
2521 adapter->mem_type_mapping_tbl = mem_type_mapping_tbl; in mwifiex_register_dev()
2522 adapter->num_mem_types = ARRAY_SIZE(mem_type_mapping_tbl); in mwifiex_register_dev()
2525 adapter->host_mlme_enabled = card->host_mlme; in mwifiex_register_dev()
2531 * This function initializes the SDIO driver.
2533 * The following initializations steps are followed -
2534 * - Read the Host interrupt status register to acknowledge
2536 * - Disable host interrupt mask register
2537 * - Get SDIO port
2538 * - Initialize SDIO variables in card
2539 * - Allocate MP registers
2540 * - Allocate MPA Tx and Rx buffers
2544 struct sdio_mmc_card *card = adapter->card; in mwifiex_init_sdio()
2545 const struct mwifiex_sdio_card_reg *reg = card->reg; in mwifiex_init_sdio()
2549 sdio_set_drvdata(card->func, card); in mwifiex_init_sdio()
2556 mwifiex_read_reg(adapter, card->reg->host_int_status_reg, &sdio_ireg); in mwifiex_init_sdio()
2558 /* Get SDIO ioport */ in mwifiex_init_sdio()
2560 return -EIO; in mwifiex_init_sdio()
2562 /* Initialize SDIO variables in card */ in mwifiex_init_sdio()
2563 card->mp_rd_bitmap = 0; in mwifiex_init_sdio()
2564 card->mp_wr_bitmap = 0; in mwifiex_init_sdio()
2565 card->curr_rd_port = reg->start_rd_port; in mwifiex_init_sdio()
2566 card->curr_wr_port = reg->start_wr_port; in mwifiex_init_sdio()
2568 card->mp_data_port_mask = reg->data_port_mask; in mwifiex_init_sdio()
2570 card->mpa_tx.buf_len = 0; in mwifiex_init_sdio()
2571 card->mpa_tx.pkt_cnt = 0; in mwifiex_init_sdio()
2572 card->mpa_tx.start_port = 0; in mwifiex_init_sdio()
2574 card->mpa_tx.enabled = 1; in mwifiex_init_sdio()
2575 card->mpa_tx.pkt_aggr_limit = card->mp_agg_pkt_limit; in mwifiex_init_sdio()
2577 card->mpa_rx.buf_len = 0; in mwifiex_init_sdio()
2578 card->mpa_rx.pkt_cnt = 0; in mwifiex_init_sdio()
2579 card->mpa_rx.start_port = 0; in mwifiex_init_sdio()
2581 card->mpa_rx.enabled = 1; in mwifiex_init_sdio()
2582 card->mpa_rx.pkt_aggr_limit = card->mp_agg_pkt_limit; in mwifiex_init_sdio()
2584 /* Allocate buffers for SDIO MP-A */ in mwifiex_init_sdio()
2585 card->mp_regs = kzalloc(reg->max_mp_regs, GFP_KERNEL); in mwifiex_init_sdio()
2586 if (!card->mp_regs) in mwifiex_init_sdio()
2587 return -ENOMEM; in mwifiex_init_sdio()
2589 card->mpa_rx.len_arr = kcalloc(card->mp_agg_pkt_limit, in mwifiex_init_sdio()
2590 sizeof(*card->mpa_rx.len_arr), in mwifiex_init_sdio()
2592 if (!card->mpa_rx.len_arr) { in mwifiex_init_sdio()
2593 kfree(card->mp_regs); in mwifiex_init_sdio()
2594 return -ENOMEM; in mwifiex_init_sdio()
2598 card->mp_tx_agg_buf_size, in mwifiex_init_sdio()
2599 card->mp_rx_agg_buf_size); in mwifiex_init_sdio()
2602 if (ret && (card->mp_tx_agg_buf_size == MWIFIEX_MP_AGGR_BUF_SIZE_MAX || in mwifiex_init_sdio()
2603 card->mp_rx_agg_buf_size == MWIFIEX_MP_AGGR_BUF_SIZE_MAX)) { in mwifiex_init_sdio()
2605 adapter->host_disable_sdio_rx_aggr = true; in mwifiex_init_sdio()
2612 card->mpa_tx.enabled = 0; in mwifiex_init_sdio()
2613 card->mpa_rx.enabled = 0; in mwifiex_init_sdio()
2617 adapter->auto_tdls = card->can_auto_tdls; in mwifiex_init_sdio()
2618 adapter->ext_scan = card->can_ext_scan; in mwifiex_init_sdio()
2627 struct sdio_mmc_card *card = adapter->card; in mwifiex_cleanup_mpa_buf()
2636 * The following are freed by this function -
2637 * - MP registers
2638 * - MPA Tx buffer
2639 * - MPA Rx buffer
2643 struct sdio_mmc_card *card = adapter->card; in mwifiex_cleanup_sdio()
2645 cancel_work_sync(&card->work); in mwifiex_cleanup_sdio()
2647 kfree(card->mp_regs); in mwifiex_cleanup_sdio()
2648 kfree(card->mpa_rx.len_arr); in mwifiex_cleanup_sdio()
2649 kfree(card->mpa_tx.buf); in mwifiex_cleanup_sdio()
2650 kfree(card->mpa_rx.buf); in mwifiex_cleanup_sdio()
2659 struct sdio_mmc_card *card = adapter->card; in mwifiex_update_mp_end_port()
2660 const struct mwifiex_sdio_card_reg *reg = card->reg; in mwifiex_update_mp_end_port()
2663 card->mp_end_port = port; in mwifiex_update_mp_end_port()
2665 card->mp_data_port_mask = reg->data_port_mask; in mwifiex_update_mp_end_port()
2667 if (reg->start_wr_port) { in mwifiex_update_mp_end_port()
2668 for (i = 1; i <= card->max_ports - card->mp_end_port; i++) in mwifiex_update_mp_end_port()
2669 card->mp_data_port_mask &= in mwifiex_update_mp_end_port()
2670 ~(1 << (card->max_ports - i)); in mwifiex_update_mp_end_port()
2673 card->curr_wr_port = reg->start_wr_port; in mwifiex_update_mp_end_port()
2677 port, card->mp_data_port_mask); in mwifiex_update_mp_end_port()
2682 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_card_reset_work()
2683 struct sdio_func *func = card->func; in mwifiex_sdio_card_reset_work()
2688 clear_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags); in mwifiex_sdio_card_reset_work()
2689 clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags); in mwifiex_sdio_card_reset_work()
2691 /* Run a HW reset of the SDIO interface. */ in mwifiex_sdio_card_reset_work()
2693 ret = mmc_hw_reset(func->card); in mwifiex_sdio_card_reset_work()
2698 dev_dbg(&func->dev, "SDIO HW reset asynchronous\n"); in mwifiex_sdio_card_reset_work()
2699 complete_all(adapter->fw_done); in mwifiex_sdio_card_reset_work()
2704 dev_err(&func->dev, "reinit failed: %d\n", ret); in mwifiex_sdio_card_reset_work()
2707 dev_err(&func->dev, "SDIO HW reset failed: %d\n", ret); in mwifiex_sdio_card_reset_work()
2717 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_rdwr_firmware()
2721 sdio_writeb(card->func, card->reg->fw_dump_host_ready, in mwifiex_sdio_rdwr_firmware()
2722 card->reg->fw_dump_ctrl, &ret); in mwifiex_sdio_rdwr_firmware()
2724 mwifiex_dbg(adapter, ERROR, "SDIO Write ERR\n"); in mwifiex_sdio_rdwr_firmware()
2728 ctrl_data = sdio_readb(card->func, card->reg->fw_dump_ctrl, in mwifiex_sdio_rdwr_firmware()
2731 mwifiex_dbg(adapter, ERROR, "SDIO read err\n"); in mwifiex_sdio_rdwr_firmware()
2738 if (ctrl_data != card->reg->fw_dump_host_ready) { in mwifiex_sdio_rdwr_firmware()
2740 "The ctrl reg was changed, re-try again\n"); in mwifiex_sdio_rdwr_firmware()
2741 sdio_writeb(card->func, card->reg->fw_dump_host_ready, in mwifiex_sdio_rdwr_firmware()
2742 card->reg->fw_dump_ctrl, &ret); in mwifiex_sdio_rdwr_firmware()
2744 mwifiex_dbg(adapter, ERROR, "SDIO write err\n"); in mwifiex_sdio_rdwr_firmware()
2750 if (ctrl_data == card->reg->fw_dump_host_ready) { in mwifiex_sdio_rdwr_firmware()
2762 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_fw_dump()
2769 if (!card->can_dump_fw) in mwifiex_sdio_fw_dump()
2775 if (entry->mem_ptr) { in mwifiex_sdio_fw_dump()
2776 vfree(entry->mem_ptr); in mwifiex_sdio_fw_dump()
2777 entry->mem_ptr = NULL; in mwifiex_sdio_fw_dump()
2779 entry->mem_size = 0; in mwifiex_sdio_fw_dump()
2783 sdio_claim_host(card->func); in mwifiex_sdio_fw_dump()
2791 reg = card->reg->fw_dump_start; in mwifiex_sdio_fw_dump()
2793 dump_num = sdio_readb(card->func, reg, &ret); in mwifiex_sdio_fw_dump()
2795 mwifiex_dbg(adapter, ERROR, "SDIO read memory length err\n"); in mwifiex_sdio_fw_dump()
2808 reg = card->reg->fw_dump_start; in mwifiex_sdio_fw_dump()
2810 read_reg = sdio_readb(card->func, reg, &ret); in mwifiex_sdio_fw_dump()
2812 mwifiex_dbg(adapter, ERROR, "SDIO read err\n"); in mwifiex_sdio_fw_dump()
2822 card->reg->fw_dump_ctrl, in mwifiex_sdio_fw_dump()
2825 mwifiex_dbg(adapter, ERROR, "SDIO write err\n"); in mwifiex_sdio_fw_dump()
2832 "%s_SIZE=0x%x\n", entry->mem_name, memory_size); in mwifiex_sdio_fw_dump()
2833 entry->mem_ptr = vmalloc(memory_size + 1); in mwifiex_sdio_fw_dump()
2834 entry->mem_size = memory_size; in mwifiex_sdio_fw_dump()
2835 if (!entry->mem_ptr) { in mwifiex_sdio_fw_dump()
2837 entry->mem_name); in mwifiex_sdio_fw_dump()
2840 dbg_ptr = entry->mem_ptr; in mwifiex_sdio_fw_dump()
2843 doneflag = entry->done_flag; in mwifiex_sdio_fw_dump()
2846 entry->mem_name); in mwifiex_sdio_fw_dump()
2853 reg_start = card->reg->fw_dump_start; in mwifiex_sdio_fw_dump()
2854 reg_end = card->reg->fw_dump_end; in mwifiex_sdio_fw_dump()
2856 *dbg_ptr = sdio_readb(card->func, reg, &ret); in mwifiex_sdio_fw_dump()
2859 "SDIO read err\n"); in mwifiex_sdio_fw_dump()
2873 entry->mem_name, dbg_ptr - entry->mem_ptr); in mwifiex_sdio_fw_dump()
2880 sdio_release_host(card->func); in mwifiex_sdio_fw_dump()
2885 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_generic_fw_dump()
2891 int ret = -1, tries; in mwifiex_sdio_generic_fw_dump()
2893 if (!card->fw_dump_enh) in mwifiex_sdio_generic_fw_dump()
2896 if (entry->mem_ptr) { in mwifiex_sdio_generic_fw_dump()
2897 vfree(entry->mem_ptr); in mwifiex_sdio_generic_fw_dump()
2898 entry->mem_ptr = NULL; in mwifiex_sdio_generic_fw_dump()
2900 entry->mem_size = 0; in mwifiex_sdio_generic_fw_dump()
2903 sdio_claim_host(card->func); in mwifiex_sdio_generic_fw_dump()
2911 reg_start = card->reg->fw_dump_start; in mwifiex_sdio_generic_fw_dump()
2912 reg_end = card->reg->fw_dump_end; in mwifiex_sdio_generic_fw_dump()
2915 start_flag = sdio_readb(card->func, reg, &ret); in mwifiex_sdio_generic_fw_dump()
2918 "SDIO read err\n"); in mwifiex_sdio_generic_fw_dump()
2926 ret = -1; in mwifiex_sdio_generic_fw_dump()
2933 entry->mem_ptr = vmalloc(0xf0000 + 1); in mwifiex_sdio_generic_fw_dump()
2934 if (!entry->mem_ptr) { in mwifiex_sdio_generic_fw_dump()
2935 ret = -1; in mwifiex_sdio_generic_fw_dump()
2938 dbg_ptr = entry->mem_ptr; in mwifiex_sdio_generic_fw_dump()
2939 entry->mem_size = 0xf0000; in mwifiex_sdio_generic_fw_dump()
2940 end_ptr = dbg_ptr + entry->mem_size; in mwifiex_sdio_generic_fw_dump()
2942 done_flag = entry->done_flag; in mwifiex_sdio_generic_fw_dump()
2944 "Start %s output, please wait...\n", entry->mem_name); in mwifiex_sdio_generic_fw_dump()
2951 *dbg_ptr = sdio_readb(card->func, reg, &ret); in mwifiex_sdio_generic_fw_dump()
2954 "SDIO read err\n"); in mwifiex_sdio_generic_fw_dump()
2961 tmp_ptr = vmalloc(entry->mem_size + 0x4000 + 1); in mwifiex_sdio_generic_fw_dump()
2965 memcpy(tmp_ptr, entry->mem_ptr, in mwifiex_sdio_generic_fw_dump()
2966 entry->mem_size); in mwifiex_sdio_generic_fw_dump()
2967 vfree(entry->mem_ptr); in mwifiex_sdio_generic_fw_dump()
2968 entry->mem_ptr = tmp_ptr; in mwifiex_sdio_generic_fw_dump()
2970 dbg_ptr = entry->mem_ptr + entry->mem_size; in mwifiex_sdio_generic_fw_dump()
2971 entry->mem_size += 0x4000; in mwifiex_sdio_generic_fw_dump()
2972 end_ptr = entry->mem_ptr + entry->mem_size; in mwifiex_sdio_generic_fw_dump()
2976 entry->mem_size = dbg_ptr - entry->mem_ptr; in mwifiex_sdio_generic_fw_dump()
2978 entry->mem_name, entry->mem_size); in mwifiex_sdio_generic_fw_dump()
2988 if (entry->mem_ptr) { in mwifiex_sdio_generic_fw_dump()
2989 vfree(entry->mem_ptr); in mwifiex_sdio_generic_fw_dump()
2990 entry->mem_ptr = NULL; in mwifiex_sdio_generic_fw_dump()
2992 entry->mem_size = 0; in mwifiex_sdio_generic_fw_dump()
2994 sdio_release_host(card->func); in mwifiex_sdio_generic_fw_dump()
2999 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_device_dump_work()
3001 adapter->devdump_data = vzalloc(MWIFIEX_FW_DUMP_SIZE); in mwifiex_sdio_device_dump_work()
3002 if (!adapter->devdump_data) { in mwifiex_sdio_device_dump_work()
3009 if (card->fw_dump_enh) in mwifiex_sdio_device_dump_work()
3023 &card->work_flags)) in mwifiex_sdio_work()
3024 mwifiex_sdio_device_dump_work(card->adapter); in mwifiex_sdio_work()
3026 &card->work_flags)) in mwifiex_sdio_work()
3027 mwifiex_sdio_card_reset_work(card->adapter); in mwifiex_sdio_work()
3033 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_card_reset()
3035 if (!test_and_set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags)) in mwifiex_sdio_card_reset()
3036 schedule_work(&card->work); in mwifiex_sdio_card_reset()
3042 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_device_dump()
3045 &card->work_flags)) in mwifiex_sdio_device_dump()
3046 schedule_work(&card->work); in mwifiex_sdio_device_dump()
3049 /* Function to dump SDIO function registers and SDIO scratch registers in case
3056 struct sdio_mmc_card *cardp = adapter->card; in mwifiex_sdio_reg_dump()
3065 mwifiex_dbg(adapter, MSG, "SDIO register dump start\n"); in mwifiex_sdio_reg_dump()
3069 sdio_claim_host(cardp->func); in mwifiex_sdio_reg_dump()
3077 /* Read the registers of SDIO function0 */ in mwifiex_sdio_reg_dump()
3083 /* Read the registers of SDIO function1 */ in mwifiex_sdio_reg_dump()
3085 reg_start = cardp->reg->func1_dump_reg_start; in mwifiex_sdio_reg_dump()
3086 reg_end = cardp->reg->func1_dump_reg_end; in mwifiex_sdio_reg_dump()
3091 reg_start = cardp->reg->func1_spec_reg_table[index++]; in mwifiex_sdio_reg_dump()
3092 size = cardp->reg->func1_spec_reg_num; in mwifiex_sdio_reg_dump()
3093 reg_end = cardp->reg->func1_spec_reg_table[size-1]; in mwifiex_sdio_reg_dump()
3096 /* Read the scratch registers of SDIO function1 */ in mwifiex_sdio_reg_dump()
3100 reg_start = cardp->reg->func1_scratch_reg; in mwifiex_sdio_reg_dump()
3105 ptr += sprintf(ptr, "SDIO Func%d (%#x-%#x): ", in mwifiex_sdio_reg_dump()
3108 ptr += sprintf(ptr, "SDIO Func%d: ", func); in mwifiex_sdio_reg_dump()
3112 data = sdio_f0_readb(cardp->func, reg, &ret); in mwifiex_sdio_reg_dump()
3114 data = sdio_readb(cardp->func, reg, &ret); in mwifiex_sdio_reg_dump()
3126 reg = cardp->reg->func1_spec_reg_table[index++]; in mwifiex_sdio_reg_dump()
3135 sdio_release_host(cardp->func); in mwifiex_sdio_reg_dump()
3137 mwifiex_dbg(adapter, MSG, "SDIO register dump end\n"); in mwifiex_sdio_reg_dump()
3139 return p - drv_buf; in mwifiex_sdio_reg_dump()
3142 /* sdio device/function initialization, code is extracted
3147 struct sdio_mmc_card *card = adapter->card; in mwifiex_sdio_up_dev()
3150 sdio_claim_host(card->func); in mwifiex_sdio_up_dev()
3151 sdio_enable_func(card->func); in mwifiex_sdio_up_dev()
3152 sdio_set_block_size(card->func, MWIFIEX_SDIO_BLOCK_SIZE); in mwifiex_sdio_up_dev()
3153 sdio_release_host(card->func); in mwifiex_sdio_up_dev()
3158 adapter->tx_buf_size = card->tx_buf_size; in mwifiex_sdio_up_dev()
3164 mwifiex_read_reg(adapter, card->reg->host_int_status_reg, &sdio_ireg); in mwifiex_sdio_up_dev()
3167 dev_err(&card->func->dev, "error enabling SDIO port\n"); in mwifiex_sdio_up_dev()
3185 /* SDIO specific */
3201 MODULE_DESCRIPTION("Marvell WiFi-Ex SDIO Driver version " SDIO_VERSION);