static int fill_ctrlset(struct zd_mac *mac, struct sk_buff *skb, struct ieee80211_tx_control *control) { int r; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; unsigned int frag_len = skb->len + FCS_LEN; unsigned int packet_length; struct zd_ctrlset *cs = (struct zd_ctrlset *) skb_push(skb, sizeof(struct zd_ctrlset)); ZD_ASSERT(frag_len <= 0xffff); cs->modulation = control->tx_rate->hw_value; if (control->flags & IEEE80211_TXCTL_SHORT_PREAMBLE) cs->modulation = control->tx_rate->hw_value_short; cs->tx_length = cpu_to_le16(frag_len); cs_set_control(mac, cs, hdr, control->flags); packet_length = frag_len + sizeof(struct zd_ctrlset) + 10; ZD_ASSERT(packet_length <= 0xffff); /* ZD1211B: Computing the length difference this way, gives us * flexibility to compute the packet length. */ cs->packet_length = cpu_to_le16(zd_chip_is_zd1211b(&mac->chip) ? packet_length - frag_len : packet_length); /* * CURRENT LENGTH: * - transmit frame length in microseconds * - seems to be derived from frame length * - see Cal_Us_Service() in zdinlinef.h * - if macp->bTxBurstEnable is enabled, then multiply by 4 * - bTxBurstEnable is never set in the vendor driver * * SERVICE: * - "for PLCP configuration" * - always 0 except in some situations at 802.11b 11M * - see line 53 of zdinlinef.h */ cs->service = 0; r = zd_calc_tx_length_us(&cs->service, ZD_RATE(cs->modulation), le16_to_cpu(cs->tx_length)); if (r < 0) return r; cs->current_length = cpu_to_le16(r); cs->next_frame_length = 0; return 0; }
int zd_rf_init_rf2959(struct zd_rf *rf) { struct zd_chip *chip = zd_rf_to_chip(rf); if (zd_chip_is_zd1211b(chip)) { dev_err(zd_chip_dev(chip), "RF2959 is currently not supported for ZD1211B" " devices\n"); return -ENODEV; } rf->init_hw = rf2959_init_hw; rf->set_channel = rf2959_set_channel; rf->switch_radio_on = rf2959_switch_radio_on; rf->switch_radio_off = rf2959_switch_radio_off; return 0; }
int zd_rf_init_al2230(struct zd_rf *rf) { struct zd_chip *chip = zd_rf_to_chip(rf); rf->switch_radio_off = al2230_switch_radio_off; if (zd_chip_is_zd1211b(chip)) { rf->init_hw = zd1211b_al2230_init_hw; rf->set_channel = zd1211b_al2230_set_channel; rf->switch_radio_on = zd1211b_al2230_switch_radio_on; } else { rf->init_hw = zd1211_al2230_init_hw; rf->set_channel = zd1211_al2230_set_channel; rf->switch_radio_on = zd1211_al2230_switch_radio_on; } rf->patch_6m_band_edge = zd_rf_generic_patch_6m; rf->patch_cck_gain = 1; return 0; }
static int uw2453_switch_radio_on(struct zd_rf *rf) { int r; struct zd_chip *chip = zd_rf_to_chip(rf); struct zd_ioreq16 ioreqs[] = { { CR11, 0x00 }, { CR251, 0x3f }, }; /* enter RXTX mode */ r = zd_rfwrite_locked(chip, UW2453_REGWRITE(0, 0x25f94), RF_RV_BITS); if (r) return r; if (zd_chip_is_zd1211b(chip)) ioreqs[1].value = 0x7f; return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); }
/* Prints an identifier line, which will support debugging. */ static int scnprint_id(struct zd_chip *chip, char *buffer, size_t size) { int i = 0; i = scnprintf(buffer, size, "zd1211%s chip ", zd_chip_is_zd1211b(chip) ? "b" : ""); i += zd_usb_scnprint_id(&chip->usb, buffer+i, size-i); i += scnprintf(buffer+i, size-i, " "); i += scnprint_mac_oui(chip, buffer+i, size-i); i += scnprintf(buffer+i, size-i, " "); i += zd_rf_scnprint_id(&chip->rf, buffer+i, size-i); i += scnprintf(buffer+i, size-i, " pa%1x %c%c%c%c%c", chip->pa_type, chip->patch_cck_gain ? 'g' : '-', chip->patch_cr157 ? '7' : '-', chip->patch_6m_band_edge ? '6' : '-', chip->new_phy_layout ? 'N' : '-', chip->al2230s_bit ? 'S' : '-'); return i; }
void zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon) { struct zd_mac *mac = zd_hw_mac(hw); u32 tmp, j = 0; /* 4 more bytes for tail CRC */ u32 full_len = beacon->len + 4; zd_iowrite32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, 0); zd_ioread32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, &tmp); while (tmp & 0x2) { zd_ioread32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, &tmp); if ((++j % 100) == 0) { printk(KERN_ERR "CR_BCN_FIFO_SEMAPHORE not ready\n"); if (j >= 500) { printk(KERN_ERR "Giving up beacon config.\n"); return; } } msleep(1); } zd_iowrite32(&mac->chip, CR_BCN_FIFO, full_len - 1); if (zd_chip_is_zd1211b(&mac->chip)) zd_iowrite32(&mac->chip, CR_BCN_LENGTH, full_len - 1); for (j = 0 ; j < beacon->len; j++) zd_iowrite32(&mac->chip, CR_BCN_FIFO, *((u8 *)(beacon->data + j))); for (j = 0; j < 4; j++) zd_iowrite32(&mac->chip, CR_BCN_FIFO, 0x0); zd_iowrite32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, 1); /* 802.11b/g 2.4G CCK 1Mb * 802.11a, not yet implemented, uses different values (see GPL vendor * driver) */ zd_iowrite32(&mac->chip, CR_BCN_PLCP_CFG, 0x00000400 | (full_len << 19)); }