/* This function parse device tree node using mmc subnode devicetree API. * The device node is saved in card->plt_of_node. * if the device tree node exist and include interrupts attributes, this * function will also request platform specific wakeup interrupt.
*/ staticint mwifiex_sdio_probe_of(struct device *dev)
{ if (!of_match_node(mwifiex_sdio_of_match_table, dev->of_node)) {
dev_err(dev, "required compatible string missing\n"); return -EINVAL;
}
return 0;
}
/* * SDIO probe. * * This function probes an mwifiex device and registers it. It allocates * the card structure, enables SDIO function number and initiates the * device registration and initialization procedure by adding a logical * interface.
*/ staticint
mwifiex_sdio_probe(struct sdio_func *func, conststruct sdio_device_id *id)
{ int ret; struct sdio_mmc_card *card = NULL;
sdio_claim_host(func);
ret = sdio_enable_func(func);
sdio_release_host(func);
if (ret) {
dev_err(&func->dev, "failed to enable function\n"); return ret;
}
/* device tree node parsing and platform specific configuration*/ if (func->dev.of_node) {
ret = mwifiex_sdio_probe_of(&func->dev); if (ret) goto err_disable;
}
ret = mwifiex_add_card(card, &card->fw_done, &sdio_ops,
MWIFIEX_SDIO, &func->dev); if (ret) {
dev_err(&func->dev, "add card failed\n"); goto err_disable;
}
/* * SDIO resume. * * Kernel needs to suspend all functions separately. Therefore all * registered functions must have drivers with suspend and resume * methods. Failing that the kernel simply removes the whole card. * * If already not resumed, this function turns on the traffic and * sends a host sleep cancel request to the firmware.
*/ staticint mwifiex_sdio_resume(struct device *dev)
{ struct sdio_func *func = dev_to_sdio_func(dev); struct sdio_mmc_card *card; struct mwifiex_adapter *adapter;
card = sdio_get_drvdata(func); if (!card || !card->adapter) {
dev_err(dev, "resume: invalid card or adapter\n"); return 0;
}
/* Write data into SDIO card register. Caller claims SDIO device. */ staticint
mwifiex_write_reg_locked(struct sdio_func *func, u32 reg, u8 data)
{ int ret = -1;
sdio_writeb(func, data, reg, &ret); return ret;
}
/* This function writes data into SDIO card register.
*/ staticint
mwifiex_write_reg(struct mwifiex_adapter *adapter, u32 reg, u8 data)
{ struct sdio_mmc_card *card = adapter->card; int ret;
sdio_claim_host(card->func);
ret = mwifiex_write_reg_locked(card->func, reg, data);
sdio_release_host(card->func);
return ret;
}
/* This function reads data from SDIO card register.
*/ staticint
mwifiex_read_reg(struct mwifiex_adapter *adapter, u32 reg, u8 *data)
{ struct sdio_mmc_card *card = adapter->card; int ret = -1;
u8 val;
sdio_claim_host(card->func);
val = sdio_readb(card->func, reg, &ret);
sdio_release_host(card->func);
*data = val;
return ret;
}
/* This function writes multiple data into SDIO card memory. * * This does not work in suspended mode.
*/ staticint
mwifiex_write_data_sync(struct mwifiex_adapter *adapter,
u8 *buffer, u32 pkt_len, u32 port)
{ struct sdio_mmc_card *card = adapter->card; int ret;
u8 blk_mode =
(port & MWIFIEX_SDIO_BYTE_MODE_MASK) ? BYTE_MODE : BLOCK_MODE;
u32 blk_size = (blk_mode == BLOCK_MODE) ? MWIFIEX_SDIO_BLOCK_SIZE : 1;
u32 blk_cnt =
(blk_mode ==
BLOCK_MODE) ? (pkt_len /
MWIFIEX_SDIO_BLOCK_SIZE) : pkt_len;
u32 ioport = (port & MWIFIEX_SDIO_IO_PORT_MASK);
if (test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) {
mwifiex_dbg(adapter, ERROR, "%s: not allowed while suspended\n", __func__); return -1;
}
sdio_claim_host(card->func);
ret = sdio_writesb(card->func, ioport, buffer, blk_cnt * blk_size);
ret = sdio_readsb(card->func, buffer, ioport, blk_cnt * blk_size);
if (claim)
sdio_release_host(card->func);
return ret;
}
/* This function reads the firmware status.
*/ staticint
mwifiex_sdio_read_fw_status(struct mwifiex_adapter *adapter, u16 *dat)
{ struct sdio_mmc_card *card = adapter->card; conststruct mwifiex_sdio_card_reg *reg = card->reg;
u8 fws0, fws1;
if (mwifiex_read_reg(adapter, reg->status_reg_0, &fws0)) return -1;
if (mwifiex_read_reg(adapter, reg->status_reg_1, &fws1)) return -1;
*dat = (u16)((fws1 << 8) | fws0); return 0;
}
/* This function checks the firmware status in card.
*/ staticint mwifiex_check_fw_status(struct mwifiex_adapter *adapter,
u32 poll_num)
{ struct sdio_mmc_card *card = adapter->card; int ret = 0;
u16 firmware_stat = 0;
u32 tries;
for (tries = 0; tries < poll_num; tries++) {
ret = mwifiex_sdio_read_fw_status(adapter, &firmware_stat); if (ret) continue; if (firmware_stat == FIRMWARE_READY_SDIO) {
ret = 0; break;
}
msleep(100);
ret = -1;
}
if (card->fw_ready_extra_delay &&
firmware_stat == FIRMWARE_READY_SDIO) /* firmware might pretend to be ready, when it's not. * Wait a little bit more as a workaround.
*/
msleep(100);
return ret;
}
/* This function checks if WLAN is the winner.
*/ staticint mwifiex_check_winner_status(struct mwifiex_adapter *adapter)
{ int ret = 0;
u8 winner = 0; struct sdio_mmc_card *card = adapter->card;
if (mwifiex_read_reg(adapter, card->reg->status_reg_0, &winner)) return -1;
if (winner)
adapter->winner = 0; else
adapter->winner = 1;
return ret;
}
/* * SDIO remove. * * This function removes the interface and frees up the card structure.
*/ staticvoid
mwifiex_sdio_remove(struct sdio_func *func)
{ struct sdio_mmc_card *card; struct mwifiex_adapter *adapter; struct mwifiex_private *priv; int ret = 0;
u16 firmware_stat;
card = sdio_get_drvdata(func); if (!card) return;
wait_for_completion(&card->fw_done);
adapter = card->adapter; if (!adapter || !adapter->priv_num) return;
/* * SDIO suspend. * * Kernel needs to suspend all functions separately. Therefore all * registered functions must have drivers with suspend and resume * methods. Failing that the kernel simply removes the whole card. * * If already not suspended, this function allocates and sends a host * sleep activate request to the firmware and turns off the traffic.
*/ staticint mwifiex_sdio_suspend(struct device *dev)
{ struct sdio_func *func = dev_to_sdio_func(dev); struct sdio_mmc_card *card; struct mwifiex_adapter *adapter;
mmc_pm_flag_t pm_flag = 0; int ret = 0;
/* * This function wakes up the card. * * A host power up command is written to the card configuration * register to wake up the card.
*/ staticint mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter)
{
mwifiex_dbg(adapter, EVENT, "event: wakeup device...\n");
/* * This function is called after the card has woken up. * * The card configuration register is reset.
*/ staticint mwifiex_pm_wakeup_card_complete(struct mwifiex_adapter *adapter)
{
mwifiex_dbg(adapter, EVENT, "cmd: wakeup device completed\n");
sdio_claim_host(card->func);
ret = mwifiex_dnld_fw(adapter, fw);
sdio_release_host(card->func);
return ret;
}
/* * This function is used to initialize IO ports for the * chipsets supporting SDIO new mode eg SD8897.
*/ staticint mwifiex_init_sdio_new_mode(struct mwifiex_adapter *adapter)
{
u8 reg; struct sdio_mmc_card *card = adapter->card;
adapter->ioport = MEM_PORT;
/* enable sdio new mode */ if (mwifiex_read_reg(adapter, card->reg->card_cfg_2_1_reg, ®)) return -1; if (mwifiex_write_reg(adapter, card->reg->card_cfg_2_1_reg,
reg | CMD53_NEW_MODE)) return -1;
/* Configure cmd port and enable reading rx length from the register */ if (mwifiex_read_reg(adapter, card->reg->cmd_cfg_0, ®)) return -1; if (mwifiex_write_reg(adapter, card->reg->cmd_cfg_0,
reg | CMD_PORT_RD_LEN_EN)) return -1;
/* Enable Dnld/Upld ready auto reset for cmd port after cmd53 is * completed
*/ if (mwifiex_read_reg(adapter, card->reg->cmd_cfg_1, ®)) return -1; if (mwifiex_write_reg(adapter, card->reg->cmd_cfg_1,
reg | CMD_PORT_AUTO_EN)) return -1;
return 0;
}
/* This function initializes the IO ports. * * The following operations are performed - * - Read the IO ports (0, 1 and 2) * - Set host interrupt Reset-To-Read to clear * - Set auto re-enable interrupt
*/ staticint mwifiex_init_sdio_ioport(struct mwifiex_adapter *adapter)
{
u8 reg; struct sdio_mmc_card *card = adapter->card;
adapter->ioport = 0;
if (card->supports_sdio_new_mode) { if (mwifiex_init_sdio_new_mode(adapter)) return -1; goto cont;
}
/* Read the IO port */ if (!mwifiex_read_reg(adapter, card->reg->io_port_0_reg, ®))
adapter->ioport |= (reg & 0xff); else return -1;
/* Set Host interrupt reset to read to clear */ if (mwifiex_read_reg(adapter, card->reg->host_int_rsr_reg, ®)) return -1; if (mwifiex_write_reg(adapter, card->reg->host_int_rsr_reg,
reg | card->reg->sdio_int_mask)) return -1;
/* Dnld/Upld ready set to auto reset */ if (mwifiex_read_reg(adapter, card->reg->card_misc_cfg_reg, ®)) return -1; if (mwifiex_write_reg(adapter, card->reg->card_misc_cfg_reg,
reg | AUTO_RE_ENABLE_INT)) return -1;
return 0;
}
/* * This function sends data to the card.
*/ staticint mwifiex_write_data_to_card(struct mwifiex_adapter *adapter,
u8 *payload, u32 pkt_len, u32 port)
{
u32 i = 0; int ret;
do {
ret = mwifiex_write_data_sync(adapter, payload, pkt_len, port); if (ret) {
i++;
mwifiex_dbg(adapter, ERROR, "host_to_card, write iomem\t" "(%d) failed: %d\n", i, ret); if (mwifiex_write_reg(adapter, CONFIGURATION_REG, 0x04))
mwifiex_dbg(adapter, ERROR, "write CFG reg failed\n");
ret = -1; if (i > MAX_WRITE_IOMEM_RETRY) return ret;
}
} while (ret == -1);
return ret;
}
/* * This function gets the read port. * * If control port bit is set in MP read bitmap, the control port * is returned, otherwise the current read port is returned and * the value is increased (provided it does not reach the maximum * limit, in which case it is reset to 1)
*/ staticint mwifiex_get_rd_port(struct mwifiex_adapter *adapter, u8 *port)
{ struct sdio_mmc_card *card = adapter->card; conststruct mwifiex_sdio_card_reg *reg = card->reg;
u32 rd_bitmap = card->mp_rd_bitmap;
/* * This function gets the write port for data. * * The current write port is returned if available and the value is * increased (provided it does not reach the maximum limit, in which * case it is reset to 1)
*/ staticint mwifiex_get_wr_port_data(struct mwifiex_adapter *adapter, u32 *port)
{ struct sdio_mmc_card *card = adapter->card; conststruct mwifiex_sdio_card_reg *reg = card->reg;
u32 wr_bitmap = card->mp_wr_bitmap;
mwifiex_dbg(adapter, ERROR, "poll card status failed, tries = %d\n", tries);
return -1;
}
/* * This function disables the host interrupt. * * The host interrupt mask is read, the disable bit is reset and * written back to the card host interrupt mask register.
*/ staticvoid mwifiex_sdio_disable_host_int(struct mwifiex_adapter *adapter)
{ struct sdio_mmc_card *card = adapter->card; struct sdio_func *func = card->func;
/* * This function reads the interrupt status from card.
*/ staticvoid mwifiex_interrupt_status(struct mwifiex_adapter *adapter)
{ struct sdio_mmc_card *card = adapter->card;
u8 sdio_ireg; unsignedlong flags;
sdio_ireg = card->mp_regs[card->reg->host_int_status_reg]; if (sdio_ireg) { /* * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS * For SDIO new mode CMD port interrupts * DN_LD_CMD_PORT_HOST_INT_STATUS and/or * UP_LD_CMD_PORT_HOST_INT_STATUS * Clear the interrupt status register
*/
mwifiex_dbg(adapter, INTR, "int: sdio_ireg = %#x\n", sdio_ireg);
spin_lock_irqsave(&adapter->int_lock, flags);
adapter->int_status |= sdio_ireg;
spin_unlock_irqrestore(&adapter->int_lock, flags);
}
}
/* * SDIO interrupt handler. * * This function reads the interrupt status from firmware and handles * the interrupt in current thread (ksdioirqd) right away.
*/ staticvoid
mwifiex_sdio_interrupt(struct sdio_func *func)
{ struct mwifiex_adapter *adapter; struct sdio_mmc_card *card;
/* * This function enables the host interrupt. * * The host interrupt enable mask is written to the card * host interrupt mask register.
*/ staticint mwifiex_sdio_enable_host_int(struct mwifiex_adapter *adapter)
{ struct sdio_mmc_card *card = adapter->card; struct sdio_func *func = card->func; int ret;
sdio_claim_host(func);
/* Request the SDIO IRQ */
ret = sdio_claim_irq(func, mwifiex_sdio_interrupt); if (ret) {
mwifiex_dbg(adapter, ERROR, "claim irq failed: ret=%d\n", ret); goto out;
}
/* Simply write the mask to the register */
ret = mwifiex_write_reg_locked(func, card->reg->host_int_mask_reg,
card->reg->host_int_enable); if (ret) {
mwifiex_dbg(adapter, ERROR, "enable host interrupt failed\n");
sdio_release_irq(func);
}
out:
sdio_release_host(func); return ret;
}
/* * This function sends a data buffer to the card.
*/ staticint mwifiex_sdio_card_to_host(struct mwifiex_adapter *adapter,
u32 *type, u8 *buffer,
u32 npayload, u32 ioport)
{ int ret;
u32 nb;
if (!buffer) {
mwifiex_dbg(adapter, ERROR, "%s: buffer is NULL\n", __func__); return -1;
}
ret = mwifiex_read_data_sync(adapter, buffer, npayload, ioport, 1);
/* * This function downloads the firmware to the card. * * Firmware is downloaded to the card in blocks. Every block download * is tested for CRC errors, and retried a number of times before * returning failure.
*/ staticint mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, struct mwifiex_fw_image *fw)
{ struct sdio_mmc_card *card = adapter->card; conststruct mwifiex_sdio_card_reg *reg = card->reg; int ret;
u8 *firmware = fw->fw_buf;
u32 firmware_len = fw->fw_len;
u32 offset = 0;
u8 base0, base1;
u8 *fwbuf;
u16 len = 0;
u32 txlen, tx_blocks = 0, tries;
u32 i = 0;
if (!firmware_len) {
mwifiex_dbg(adapter, ERROR, "firmware image not found! Terminating download\n"); return -1;
}
/* Assume that the allocated buffer is 8-byte aligned */
fwbuf = kzalloc(MWIFIEX_UPLD_SIZE, GFP_KERNEL); if (!fwbuf) return -ENOMEM;
sdio_claim_host(card->func);
/* Perform firmware data transfer */ do { /* The host polls for the DN_LD_CARD_RDY and CARD_IO_READY
bits */
ret = mwifiex_sdio_poll_card_status(adapter, CARD_IO_READY |
DN_LD_CARD_RDY); if (ret) {
mwifiex_dbg(adapter, ERROR, "FW download with helper:\t" "poll status timeout @ %d\n", offset); goto done;
}
/* More data? */ if (offset >= firmware_len) break;
if (len & BIT(0)) {
i++; if (i > MAX_WRITE_IOMEM_RETRY) {
mwifiex_dbg(adapter, ERROR, "FW dnld failed @ %d, over max retry\n",
offset);
ret = -1; goto done;
}
mwifiex_dbg(adapter, ERROR, "CRC indicated by the helper:\t" "len = 0x%04X, txlen = %d\n", len, txlen);
len &= ~BIT(0); /* Setting this to 0 to resend from same offset */
txlen = 0;
} else {
i = 0;
/* Set blocksize to transfer - checking for last
block */ if (firmware_len - offset < txlen)
txlen = firmware_len - offset;
ret = 0;
done:
sdio_release_host(card->func);
kfree(fwbuf); return ret;
}
/* * This function decodes sdio aggregation pkt. * * Based on the data block size and pkt_len, * skb data will be decoded to few packets.
*/ staticvoid mwifiex_deaggr_sdio_pkt(struct mwifiex_adapter *adapter, struct sk_buff *skb)
{
u32 total_pkt_len, pkt_len; struct sk_buff *skb_deaggr;
u16 blk_size;
u8 blk_num;
u8 *data;
skb_deaggr = mwifiex_alloc_dma_align_buf(pkt_len, GFP_KERNEL); if (!skb_deaggr) break;
skb_put(skb_deaggr, pkt_len);
memcpy(skb_deaggr->data, data + SDIO_HEADER_OFFSET, pkt_len);
skb_pull(skb_deaggr, adapter->intf_hdr_len);
mwifiex_handle_rx_packet(adapter, skb_deaggr);
data += blk_size;
total_pkt_len -= blk_size;
}
}
/* * This function decodes a received packet. * * Based on the type, the packet is treated as either a data, or * a command response, or an event, and the correct handler * function is invoked.
*/ staticint mwifiex_decode_rx_packet(struct mwifiex_adapter *adapter, struct sk_buff *skb, u32 upld_typ)
{
u8 *cmd_buf;
u16 pkt_len; struct mwifiex_rxinfo *rx_info;
pkt_len = get_unaligned_le16(skb->data);
if (upld_typ != MWIFIEX_TYPE_AGGR_DATA) {
skb_trim(skb, pkt_len);
skb_pull(skb, adapter->intf_hdr_len);
}
case MWIFIEX_TYPE_DATA:
mwifiex_dbg(adapter, DATA, "info: --- Rx: Data packet ---\n"); if (adapter->rx_work_enabled) {
skb_queue_tail(&adapter->rx_data_q, skb);
adapter->data_received = true;
atomic_inc(&adapter->rx_pending);
} else {
mwifiex_handle_rx_packet(adapter, skb);
} break;
case MWIFIEX_TYPE_CMD:
mwifiex_dbg(adapter, CMD, "info: --- Rx: Cmd Response ---\n"); /* take care of curr_cmd = NULL case */ if (!adapter->curr_cmd) {
cmd_buf = adapter->upld_buf;
if (adapter->ps_state == PS_STATE_SLEEP_CFM)
mwifiex_process_sleep_confirm_resp(adapter,
skb->data,
skb->len);
/* * This function transfers received packets from card to driver, performing * aggregation if required. * * For data received on control port, or if aggregation is disabled, the * received buffers are uploaded as separate packets. However, if aggregation * is enabled and required, the buffers are copied onto an aggregation buffer, * provided there is space left, processed and finally uploaded.
*/ staticint mwifiex_sdio_card_to_host_mp_aggr(struct mwifiex_adapter *adapter,
u16 rx_len, u8 port)
{ struct sdio_mmc_card *card = adapter->card;
s32 f_do_rx_aggr = 0;
s32 f_do_rx_cur = 0;
s32 f_aggr_cur = 0;
s32 f_post_aggr_cur = 0; struct sk_buff *skb_deaggr; struct sk_buff *skb = NULL;
u32 pkt_len, pkt_type, mport, pind;
u8 *curr_ptr;
if ((card->has_control_mask) && (port == CTRL_PORT)) { /* Read the command Resp without aggr */
mwifiex_dbg(adapter, CMD, "info: %s: no aggregation for cmd\t" "response\n", __func__);
if ((!card->has_control_mask && (card->mp_rd_bitmap &
card->reg->data_port_mask)) ||
(card->has_control_mask && (card->mp_rd_bitmap &
(~((u32) CTRL_PORT_MASK))))) { /* Some more data RX pending */
mwifiex_dbg(adapter, INFO, "info: %s: not last packet\n", __func__);
if (MP_RX_AGGR_IN_PROGRESS(card)) { if (MP_RX_AGGR_BUF_HAS_ROOM(card, rx_len)) {
f_aggr_cur = 1;
} else { /* No room in Aggr buf, do rx aggr now */
f_do_rx_aggr = 1;
f_post_aggr_cur = 1;
}
} else { /* Rx aggr not in progress */
f_aggr_cur = 1;
}
} else { /* No more data RX pending */
mwifiex_dbg(adapter, INFO, "info: %s: last packet\n", __func__);
if (MP_RX_AGGR_IN_PROGRESS(card)) {
f_do_rx_aggr = 1; if (MP_RX_AGGR_BUF_HAS_ROOM(card, rx_len))
f_aggr_cur = 1; else /* No room in Aggr buf, do rx aggr now */
f_do_rx_cur = 1;
} else {
f_do_rx_cur = 1;
}
}
if (f_aggr_cur) {
mwifiex_dbg(adapter, INFO, "info: current packet aggregation\n"); /* Curr pkt can be aggregated */
mp_rx_aggr_setup(card, rx_len, port);
if (MP_RX_AGGR_PKT_LIMIT_REACHED(card) ||
mp_rx_aggr_port_limit_reached(card)) {
mwifiex_dbg(adapter, INFO, "info: %s: aggregated packet\t" "limit reached\n", __func__); /* No more pkts allowed in Aggr buf, rx it */
f_do_rx_aggr = 1;
}
}
if (f_do_rx_aggr) { /* do aggr RX now */
mwifiex_dbg(adapter, DATA, "info: do_rx_aggr: num of packets: %d\n",
card->mpa_rx.pkt_cnt);
if (card->supports_sdio_new_mode) { int i;
u32 port_count;
for (i = 0, port_count = 0; i < card->max_ports; i++) if (card->mpa_rx.ports & BIT(i))
port_count++;
/* Reading data from "start_port + 0" to "start_port + * port_count -1", so decrease the count by 1
*/
port_count--;
mport = (adapter->ioport | SDIO_MPA_ADDR_BASE |
(port_count << 8)) + card->mpa_rx.start_port;
} else {
mport = (adapter->ioport | SDIO_MPA_ADDR_BASE |
(card->mpa_rx.ports << 4)) +
card->mpa_rx.start_port;
}
if (card->mpa_rx.pkt_cnt == 1)
mport = adapter->ioport + card->mpa_rx.start_port;
if (mwifiex_read_data_sync(adapter, card->mpa_rx.buf,
card->mpa_rx.buf_len, mport, 1)) goto error;
curr_ptr = card->mpa_rx.buf;
for (pind = 0; pind < card->mpa_rx.pkt_cnt; pind++) {
u32 *len_arr = card->mpa_rx.len_arr;
/* get curr PKT len & type */
pkt_len = get_unaligned_le16(&curr_ptr[0]);
pkt_type = get_unaligned_le16(&curr_ptr[2]);
if (mwifiex_sdio_card_to_host(adapter, &pkt_type,
skb->data, skb->len,
adapter->ioport + port)) goto error; if (!adapter->sdio_rx_aggr_enable &&
pkt_type == MWIFIEX_TYPE_AGGR_DATA) {
mwifiex_dbg(adapter, ERROR, "drop wrong pkt type %d\t" "current SDIO RX Aggr not enabled\n",
pkt_type);
dev_kfree_skb_any(skb); return 0;
}
mwifiex_decode_rx_packet(adapter, skb, pkt_type);
} if (f_post_aggr_cur) {
mwifiex_dbg(adapter, INFO, "info: current packet aggregation\n"); /* Curr pkt can be aggregated */
mp_rx_aggr_setup(card, rx_len, port);
}
return 0;
error: if (MP_RX_AGGR_IN_PROGRESS(card))
MP_RX_AGGR_BUF_RESET(card);
if (f_do_rx_cur && skb) /* Single transfer pending. Free curr buff also */
dev_kfree_skb_any(skb);
return -1;
}
/* * This function checks the current interrupt status. * * The following interrupts are checked and handled by this function - * - Data sent * - Command sent * - Packets received * * Since the firmware does not generate download ready interrupt if the * port updated is command port only, command sent interrupt checking * should be done manually, and for every SDIO interrupt. * * In case of Rx packets received, the packets are uploaded from card to * host and processed accordingly.
*/ staticint mwifiex_process_int_status(struct mwifiex_adapter *adapter)
{ struct sdio_mmc_card *card = adapter->card; conststruct mwifiex_sdio_card_reg *reg = card->reg; int ret = 0;
u8 sdio_ireg; struct sk_buff *skb;
u8 port = CTRL_PORT;
u32 len_reg_l, len_reg_u;
u32 rx_blocks;
u16 rx_len; unsignedlong flags;
u32 bitmap;
u8 cr;
/* As firmware will not generate download ready interrupt if the port updated is command port only, cmd_sent should be done for any SDIO
interrupt. */ if (card->has_control_mask && adapter->cmd_sent) { /* Check if firmware has attach buffer at command port and
update just that in wr_bit_map. */
card->mp_wr_bitmap |=
(u32) card->mp_regs[reg->wr_bitmap_l] & CTRL_PORT_MASK; if (card->mp_wr_bitmap & CTRL_PORT_MASK)
adapter->cmd_sent = false;
}
if (mwifiex_read_reg(adapter, CONFIGURATION_REG, &cr))
mwifiex_dbg(adapter, ERROR, "read CFG reg failed\n"); else
mwifiex_dbg(adapter, INFO, "info: CFG reg val =%x\n", cr);
return -1;
}
/* * This function aggregates transmission buffers in driver and downloads * the aggregated packet to card. * * The individual packets are aggregated by copying into an aggregation * buffer and then downloaded to the card. Previous unsent packets in the * aggregation buffer are pre-copied first before new packets are added. * Aggregation is done till there is space left in the aggregation buffer, * or till new packets are available. * * The function will only download the packet to the card when aggregation * stops, otherwise it will just aggregate the packet in aggregation buffer * and return.
*/ staticint mwifiex_host_to_card_mp_aggr(struct mwifiex_adapter *adapter,
u8 *payload, u32 pkt_len, u32 port,
u32 next_pkt_len)
{ struct sdio_mmc_card *card = adapter->card; int ret = 0;
s32 f_send_aggr_buf = 0;
s32 f_send_cur_buf = 0;
s32 f_precopy_cur_buf = 0;
s32 f_postcopy_cur_buf = 0;
u32 mport; int index;
if (next_pkt_len) { /* More pkt in TX queue */
mwifiex_dbg(adapter, INFO, "info: %s: more packets in queue.\n",
__func__);
if (MP_TX_AGGR_IN_PROGRESS(card)) { if (MP_TX_AGGR_BUF_HAS_ROOM(card, pkt_len)) {
f_precopy_cur_buf = 1;
if (!(card->mp_wr_bitmap &
(1 << card->curr_wr_port)) ||
!MP_TX_AGGR_BUF_HAS_ROOM(
card, pkt_len + next_pkt_len))
f_send_aggr_buf = 1;
} else { /* No room in Aggr buf, send it */
f_send_aggr_buf = 1;
if (!(card->mp_wr_bitmap &
(1 << card->curr_wr_port)))
f_send_cur_buf = 1; else
f_postcopy_cur_buf = 1;
}
} else { if (MP_TX_AGGR_BUF_HAS_ROOM(card, pkt_len) &&
(card->mp_wr_bitmap & (1 << card->curr_wr_port)))
f_precopy_cur_buf = 1; else
f_send_cur_buf = 1;
}
} else { /* Last pkt in TX queue */
mwifiex_dbg(adapter, INFO, "info: %s: Last packet in Tx Queue.\n",
__func__);
if (MP_TX_AGGR_IN_PROGRESS(card)) { /* some packs in Aggr buf already */
f_send_aggr_buf = 1;
if (MP_TX_AGGR_BUF_HAS_ROOM(card, pkt_len))
f_precopy_cur_buf = 1; else /* No room in Aggr buf, send it */
f_send_cur_buf = 1;
} else {
f_send_cur_buf = 1;
}
}
if (f_precopy_cur_buf) {
mwifiex_dbg(adapter, DATA, "data: %s: precopy current buffer\n",
__func__);
MP_TX_AGGR_BUF_PUT(card, payload, pkt_len, port);
if (MP_TX_AGGR_PKT_LIMIT_REACHED(card) ||
mp_tx_aggr_port_limit_reached(card)) /* No more pkts allowed in Aggr buf, send it */
f_send_aggr_buf = 1;
}
if (f_send_aggr_buf) {
mwifiex_dbg(adapter, DATA, "data: %s: send aggr buffer: %d %d\n",
__func__, card->mpa_tx.start_port,
card->mpa_tx.ports); if (card->supports_sdio_new_mode) {
u32 port_count; int i;
for (i = 0, port_count = 0; i < card->max_ports; i++) if (card->mpa_tx.ports & BIT(i))
port_count++;
/* Writing data from "start_port + 0" to "start_port + * port_count -1", so decrease the count by 1
*/
port_count--;
mport = (adapter->ioport | SDIO_MPA_ADDR_BASE |
(port_count << 8)) + card->mpa_tx.start_port;
} else {
mport = (adapter->ioport | SDIO_MPA_ADDR_BASE |
(card->mpa_tx.ports << 4)) +
card->mpa_tx.start_port;
}
if (card->mpa_tx.pkt_cnt == 1)
mport = adapter->ioport + card->mpa_tx.start_port;
ret = mwifiex_write_data_to_card(adapter, card->mpa_tx.buf,
card->mpa_tx.buf_len, mport);
/* Save the last multi port tx aggregation info to debug log. */
index = adapter->dbg.last_sdio_mp_index;
index = (index + 1) % MWIFIEX_DBG_SDIO_MP_NUM;
adapter->dbg.last_sdio_mp_index = index;
adapter->dbg.last_mp_wr_ports[index] = mport;
adapter->dbg.last_mp_wr_bitmap[index] = card->mp_wr_bitmap;
adapter->dbg.last_mp_wr_len[index] = card->mpa_tx.buf_len;
adapter->dbg.last_mp_curr_wr_port[index] = card->curr_wr_port;
MP_TX_AGGR_BUF_RESET(card);
}
tx_curr_single: if (f_send_cur_buf) {
mwifiex_dbg(adapter, DATA, "data: %s: send current buffer %d\n",
__func__, port);
ret = mwifiex_write_data_to_card(adapter, payload, pkt_len,
adapter->ioport + port);
}
if (f_postcopy_cur_buf) {
mwifiex_dbg(adapter, DATA, "data: %s: postcopy current buffer\n",
__func__);
MP_TX_AGGR_BUF_PUT(card, payload, pkt_len, port);
}
return ret;
}
/* * This function downloads data from driver to card. * * Both commands and data packets are transferred to the card by this * function. * * This function adds the SDIO specific header to the front of the buffer * before transferring. The header contains the length of the packet and * the type. The firmware handles the packets based upon this set type.
*/ staticint mwifiex_sdio_host_to_card(struct mwifiex_adapter *adapter,
u8 type, struct sk_buff *skb, struct mwifiex_tx_param *tx_param)
{ struct sdio_mmc_card *card = adapter->card; int ret;
u32 buf_block_len;
u32 blk_size;
u32 port = CTRL_PORT;
u8 *payload = (u8 *)skb->data;
u32 pkt_len = skb->len;
/* * This function unregisters the SDIO device. * * The SDIO IRQ is released, the function is disabled and driver * data is set to null.
*/ staticvoid
mwifiex_unregister_dev(struct mwifiex_adapter *adapter)
{ struct sdio_mmc_card *card = adapter->card;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.