Lines Matching +full:ieee80211 +full:- +full:freq +full:- +full:limit
8 * Copyright 2004-2005 Andrea Merello <andrea.merello@gmail.com>, et al.
18 * - portions of rtl8187se Linux staging driver, Copyright Realtek corp.
20 * - other GPL, unpublished (until now), Linux driver code,
24 * sitting in front of my laptop at evening, week-end, night...
28 * bought a laptop with an unsupported Wi-Fi card some years ago...
139 * BC | 7 | 4 <- currently not used yet
140 * MG | 1 | x <- Not used
141 * HI | 6 | x <- Not used
142 * VO | 5 | 0 <- used
143 * VI | 4 | 1 <- used
144 * BE | 3 | 2 <- used
145 * BK | 2 | 3 <- used
151 * - I'm unsure whether the mac80211 will ever try to use more than 4 queues
154 * - I could route MGMT frames (currently sent over VO queue) to the MGMT
161 * - I don't know how to set in the HW the contention window params for MGMT
162 * and HI-prio queues.
184 * BC | 7 | 1 <- currently not used yet.
185 * HI | 6 | x <- not used
186 * NO | 5 | x <- not used
187 * LO | 4 | 0 <- used
197 struct rtl8180_priv *priv = dev->priv; in rtl8180_write_phy()
203 rtl818x_iowrite32(priv, (__le32 __iomem *)&priv->map->PHY[0], buf | 0x80); in rtl8180_write_phy()
204 while (i--) { in rtl8180_write_phy()
205 rtl818x_iowrite32(priv, (__le32 __iomem *)&priv->map->PHY[0], buf); in rtl8180_write_phy()
206 if (rtl818x_ioread8(priv, &priv->map->PHY[2]) == (data & 0xFF)) in rtl8180_write_phy()
213 struct rtl8180_priv *priv = dev->priv; in rtl8180_handle_rx()
220 while (count--) { in rtl8180_handle_rx()
221 void *entry = priv->rx_ring + priv->rx_idx * priv->rx_ring_sz; in rtl8180_handle_rx()
222 struct sk_buff *skb = priv->rx_buf[priv->rx_idx]; in rtl8180_handle_rx()
226 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_handle_rx()
229 flags = le32_to_cpu(desc->flags); in rtl8180_handle_rx()
236 flags3 = le32_to_cpu(desc->flags3); in rtl8180_handle_rx()
237 flags2 = le32_to_cpu(desc->flags2); in rtl8180_handle_rx()
238 tsft = le64_to_cpu(desc->tsft); in rtl8180_handle_rx()
242 flags = le32_to_cpu(desc->flags); in rtl8180_handle_rx()
245 flags2 = le32_to_cpu(desc->flags2); in rtl8180_handle_rx()
246 tsft = le64_to_cpu(desc->tsft); in rtl8180_handle_rx()
263 mapping = dma_map_single(&priv->pdev->dev, in rtl8180_handle_rx()
267 if (dma_mapping_error(&priv->pdev->dev, mapping)) { in rtl8180_handle_rx()
269 dev_err(&priv->pdev->dev, "RX DMA map error\n"); in rtl8180_handle_rx()
274 dma_unmap_single(&priv->pdev->dev, in rtl8180_handle_rx()
275 *((dma_addr_t *)skb->cb), in rtl8180_handle_rx()
283 switch (priv->chip_family) { in rtl8180_handle_rx()
286 signal = -clamp_t(u8, agc, 25, 90) - 9; in rtl8180_handle_rx()
288 signal = -clamp_t(u8, agc, 30, 95); in rtl8180_handle_rx()
292 signal = priv->rf->calc_rssi(agc, sq); in rtl8180_handle_rx()
296 * in 0.5dBm unit, with zero centered @ -41dBm in rtl8180_handle_rx()
301 signal = signal / 2 - 41; in rtl8180_handle_rx()
308 signal = 4 - bb - rtl8187se_lna_gain[idx]; in rtl8180_handle_rx()
313 rx_status.freq = dev->conf.chandef.chan->center_freq; in rtl8180_handle_rx()
314 rx_status.band = dev->conf.chandef.chan->band; in rtl8180_handle_rx()
326 priv->rx_buf[priv->rx_idx] = skb; in rtl8180_handle_rx()
327 *((dma_addr_t *) skb->cb) = mapping; in rtl8180_handle_rx()
332 cmd_desc->rx_buf = cpu_to_le32(*((dma_addr_t *)skb->cb)); in rtl8180_handle_rx()
333 cmd_desc->flags = cpu_to_le32(RTL818X_RX_DESC_FLAG_OWN | in rtl8180_handle_rx()
335 if (priv->rx_idx == 31) in rtl8180_handle_rx()
336 cmd_desc->flags |= in rtl8180_handle_rx()
338 priv->rx_idx = (priv->rx_idx + 1) % 32; in rtl8180_handle_rx()
344 struct rtl8180_priv *priv = dev->priv; in rtl8180_handle_tx()
345 struct rtl8180_tx_ring *ring = &priv->tx_ring[prio]; in rtl8180_handle_tx()
347 while (skb_queue_len(&ring->queue)) { in rtl8180_handle_tx()
348 struct rtl8180_tx_desc *entry = &ring->desc[ring->idx]; in rtl8180_handle_tx()
351 u32 flags = le32_to_cpu(entry->flags); in rtl8180_handle_tx()
356 ring->idx = (ring->idx + 1) % ring->entries; in rtl8180_handle_tx()
357 skb = __skb_dequeue(&ring->queue); in rtl8180_handle_tx()
358 dma_unmap_single(&priv->pdev->dev, le32_to_cpu(entry->tx_buf), in rtl8180_handle_tx()
359 skb->len, DMA_TO_DEVICE); in rtl8180_handle_tx()
364 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) && in rtl8180_handle_tx()
366 info->flags |= IEEE80211_TX_STAT_ACK; in rtl8180_handle_tx()
368 info->status.rates[0].count = (flags & 0xFF) + 1; in rtl8180_handle_tx()
371 if (ring->entries - skb_queue_len(&ring->queue) == 2) in rtl8180_handle_tx()
379 struct rtl8180_priv *priv = dev->priv; in rtl8187se_interrupt()
384 spin_lock_irqsave(&priv->lock, flags); in rtl8187se_interrupt()
385 /* Note: 32-bit interrupt status */ in rtl8187se_interrupt()
386 reg = rtl818x_ioread32(priv, &priv->map->INT_STATUS_SE); in rtl8187se_interrupt()
388 spin_unlock_irqrestore(&priv->lock, flags); in rtl8187se_interrupt()
392 rtl818x_iowrite32(priv, &priv->map->INT_STATUS_SE, reg); in rtl8187se_interrupt()
395 rtl818x_iowrite32(priv, &priv->map->INT_TIMEOUT, 0); in rtl8187se_interrupt()
419 wiphy_err(dev->wiphy, "No RX DMA Descriptor avail\n"); in rtl8187se_interrupt()
421 spin_unlock_irqrestore(&priv->lock, flags); in rtl8187se_interrupt()
428 struct rtl8180_priv *priv = dev->priv; in rtl8180_interrupt()
431 spin_lock(&priv->lock); in rtl8180_interrupt()
432 reg = rtl818x_ioread16(priv, &priv->map->INT_STATUS); in rtl8180_interrupt()
434 spin_unlock(&priv->lock); in rtl8180_interrupt()
438 rtl818x_iowrite16(priv, &priv->map->INT_STATUS, reg); in rtl8180_interrupt()
449 spin_unlock(&priv->lock); in rtl8180_interrupt()
459 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in rtl8180_tx()
460 struct rtl8180_priv *priv = dev->priv; in rtl8180_tx()
476 if (dev->queues > IEEE80211_AC_BK) in rtl8180_tx()
478 ring = &priv->tx_ring[prio]; in rtl8180_tx()
480 mapping = dma_map_single(&priv->pdev->dev, skb->data, skb->len, in rtl8180_tx()
483 if (dma_mapping_error(&priv->pdev->dev, mapping)) { in rtl8180_tx()
485 dev_err(&priv->pdev->dev, "TX DMA mapping error\n"); in rtl8180_tx()
491 (ieee80211_get_tx_rate(dev, info)->hw_value << 24) | in rtl8180_tx()
492 skb->len; in rtl8180_tx()
494 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_tx()
498 rc_flags = info->control.rates[0].flags; in rtl8180_tx()
500 /* HW will perform RTS-CTS when only RTS flags is set. in rtl8180_tx()
501 * HW will perform CTS-to-self when both RTS and CTS flags are set. in rtl8180_tx()
502 * RTS rate and RTS duration will be used also for CTS-to-self. in rtl8180_tx()
506 tx_flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19; in rtl8180_tx()
507 rts_duration = ieee80211_rts_duration(dev, priv->vif, in rtl8180_tx()
508 skb->len, info); in rtl8180_tx()
511 tx_flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19; in rtl8180_tx()
512 rts_duration = ieee80211_ctstoself_duration(dev, priv->vif, in rtl8180_tx()
513 skb->len, info); in rtl8180_tx()
516 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_tx()
519 plcp_len = DIV_ROUND_UP(16 * (skb->len + 4), in rtl8180_tx()
520 (ieee80211_get_tx_rate(dev, info)->bitrate * 2) / 10); in rtl8180_tx()
521 remainder = (16 * (skb->len + 4)) % in rtl8180_tx()
522 ((ieee80211_get_tx_rate(dev, info)->bitrate * 2) / 10); in rtl8180_tx()
527 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_tx()
532 duration = ieee80211_generic_frame_duration(dev, priv->vif, in rtl8180_tx()
533 NL80211_BAND_2GHZ, skb->len, in rtl8180_tx()
536 frame_duration = priv->ack_time + le16_to_cpu(duration); in rtl8180_tx()
539 spin_lock_irqsave(&priv->lock, flags); in rtl8180_tx()
541 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { in rtl8180_tx()
542 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) in rtl8180_tx()
543 priv->seqno += 0x10; in rtl8180_tx()
544 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); in rtl8180_tx()
545 hdr->seq_ctrl |= cpu_to_le16(priv->seqno); in rtl8180_tx()
548 idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; in rtl8180_tx()
549 entry = &ring->desc[idx]; in rtl8180_tx()
551 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_tx()
552 entry->frame_duration = cpu_to_le16(frame_duration); in rtl8180_tx()
553 entry->frame_len_se = cpu_to_le16(skb->len); in rtl8180_tx()
556 entry->flags3 = cpu_to_le16(1<<4); in rtl8180_tx()
558 entry->frame_len = cpu_to_le32(skb->len); in rtl8180_tx()
560 entry->rts_duration = rts_duration; in rtl8180_tx()
561 entry->plcp_len = cpu_to_le16(plcp_len); in rtl8180_tx()
562 entry->tx_buf = cpu_to_le32(mapping); in rtl8180_tx()
564 entry->retry_limit = info->control.rates[0].count - 1; in rtl8180_tx()
570 entry->flags = cpu_to_le32(tx_flags); in rtl8180_tx()
573 * to DMA the just-written data in rtl8180_tx()
577 __skb_queue_tail(&ring->queue, skb); in rtl8180_tx()
578 if (ring->entries - skb_queue_len(&ring->queue) < 2) in rtl8180_tx()
581 spin_unlock_irqrestore(&priv->lock, flags); in rtl8180_tx()
583 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_tx()
586 rtl818x_iowrite8(priv, &priv->map->TX_DMA_POLLING, in rtl8180_tx()
590 rtl818x_iowrite8(priv, &priv->map->TX_DMA_POLLING, in rtl8180_tx()
600 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, in rtl8180_set_anaparam3()
603 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); in rtl8180_set_anaparam3()
604 rtl818x_iowrite8(priv, &priv->map->CONFIG3, in rtl8180_set_anaparam3()
607 rtl818x_iowrite16(priv, &priv->map->ANAPARAM3, anaparam3); in rtl8180_set_anaparam3()
609 rtl818x_iowrite8(priv, &priv->map->CONFIG3, in rtl8180_set_anaparam3()
612 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, in rtl8180_set_anaparam3()
620 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, in rtl8180_set_anaparam2()
623 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); in rtl8180_set_anaparam2()
624 rtl818x_iowrite8(priv, &priv->map->CONFIG3, in rtl8180_set_anaparam2()
627 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2, anaparam2); in rtl8180_set_anaparam2()
629 rtl818x_iowrite8(priv, &priv->map->CONFIG3, in rtl8180_set_anaparam2()
632 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, in rtl8180_set_anaparam2()
640 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); in rtl8180_set_anaparam()
641 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); in rtl8180_set_anaparam()
642 rtl818x_iowrite8(priv, &priv->map->CONFIG3, in rtl8180_set_anaparam()
644 rtl818x_iowrite32(priv, &priv->map->ANAPARAM, anaparam); in rtl8180_set_anaparam()
645 rtl818x_iowrite8(priv, &priv->map->CONFIG3, in rtl8180_set_anaparam()
647 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); in rtl8180_set_anaparam()
652 struct rtl8180_priv *priv = dev->priv; in rtl8187se_mac_config()
662 reg = rtl818x_ioread8(priv, &priv->map->PHY_PR); in rtl8187se_mac_config()
663 rtl818x_iowrite8(priv, &priv->map->PHY_PR, reg | 0x04); in rtl8187se_mac_config()
667 /* AFE - default to power ON */ in rtl8187se_mac_config()
684 struct rtl8180_priv *priv = dev->priv; in rtl8187se_set_antenna_config()
689 rtl818x_iowrite8(priv, &priv->map->TX_ANTENNA, 0x00); in rtl8187se_set_antenna_config()
695 rtl818x_iowrite8(priv, &priv->map->TX_ANTENNA, 0x03); in rtl8187se_set_antenna_config()
703 rtl818x_iowrite8(priv, &priv->map->TX_ANTENNA, 0x00); in rtl8187se_set_antenna_config()
709 rtl818x_iowrite8(priv, &priv->map->TX_ANTENNA, 0x03); in rtl8187se_set_antenna_config()
716 /* priv->curr_ant = def_ant; */ in rtl8187se_set_antenna_config()
721 struct rtl8180_priv *priv = dev->priv; in rtl8180_int_enable()
723 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_int_enable()
724 rtl818x_iowrite32(priv, &priv->map->IMR, in rtl8180_int_enable()
733 rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0xFFFF); in rtl8180_int_enable()
739 struct rtl8180_priv *priv = dev->priv; in rtl8180_int_disable()
741 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_int_disable()
742 rtl818x_iowrite32(priv, &priv->map->IMR, 0); in rtl8180_int_disable()
744 rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0); in rtl8180_int_disable()
751 struct rtl8180_priv *priv = dev->priv; in rtl8180_conf_basic_rates()
758 /* IEEE80211 says the response rate should be equal to the highest basic in rtl8180_conf_basic_rates()
767 switch (priv->chip_family) { in rtl8180_conf_basic_rates()
771 basic_max = fls(basic_mask) - 1; in rtl8180_conf_basic_rates()
772 reg = rtl818x_ioread16(priv, &priv->map->BRSR); in rtl8180_conf_basic_rates()
775 rtl818x_iowrite16(priv, &priv->map->BRSR, reg); in rtl8180_conf_basic_rates()
779 resp_max = fls(resp_mask) - 1; in rtl8180_conf_basic_rates()
780 resp_min = ffs(resp_mask) - 1; in rtl8180_conf_basic_rates()
782 rtl818x_iowrite16(priv, &priv->map->BRSR, basic_mask); in rtl8180_conf_basic_rates()
783 rtl818x_iowrite8(priv, &priv->map->RESP_RATE, (resp_max << 4) | in rtl8180_conf_basic_rates()
791 rtl818x_iowrite16(priv, &priv->map->BRSR_8187SE, resp_mask); in rtl8180_conf_basic_rates()
798 struct rtl8180_priv *priv = dev->priv; in rtl8180_config_cardbus()
802 reg8 = rtl818x_ioread8(priv, &priv->map->CONFIG3); in rtl8180_config_cardbus()
804 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg8); in rtl8180_config_cardbus()
806 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_config_cardbus()
809 reg16 = rtl818x_ioread16(priv, &priv->map->FEMR); in rtl8180_config_cardbus()
811 rtl818x_iowrite16(priv, &priv->map->FEMR, reg16); in rtl8180_config_cardbus()
818 struct rtl8180_priv *priv = dev->priv; in rtl8180_init_hw()
822 rtl818x_iowrite8(priv, &priv->map->CMD, 0); in rtl8180_init_hw()
823 rtl818x_ioread8(priv, &priv->map->CMD); in rtl8180_init_hw()
828 rtl818x_ioread8(priv, &priv->map->CMD); in rtl8180_init_hw()
830 reg = rtl818x_ioread8(priv, &priv->map->CMD); in rtl8180_init_hw()
833 rtl818x_iowrite8(priv, &priv->map->CMD, RTL818X_CMD_RESET); in rtl8180_init_hw()
834 rtl818x_ioread8(priv, &priv->map->CMD); in rtl8180_init_hw()
838 if (rtl818x_ioread8(priv, &priv->map->CMD) & RTL818X_CMD_RESET) { in rtl8180_init_hw()
839 wiphy_err(dev->wiphy, "reset timeout!\n"); in rtl8180_init_hw()
840 return -ETIMEDOUT; in rtl8180_init_hw()
843 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_LOAD); in rtl8180_init_hw()
844 rtl818x_ioread8(priv, &priv->map->CMD); in rtl8180_init_hw()
847 if (rtl818x_ioread8(priv, &priv->map->CONFIG3) & (1 << 3)) { in rtl8180_init_hw()
851 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_init_hw()
852 rtl818x_iowrite8(priv, &priv->map->MSR, RTL818X_MSR_ENEDCA); in rtl8180_init_hw()
854 rtl818x_iowrite8(priv, &priv->map->MSR, 0); in rtl8180_init_hw()
856 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_init_hw()
857 rtl8180_set_anaparam(priv, priv->anaparam); in rtl8180_init_hw()
859 rtl818x_iowrite32(priv, &priv->map->RDSAR, priv->rx_ring_dma); in rtl8180_init_hw()
864 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_init_hw()
865 rtl818x_iowrite32(priv, &priv->map->TBDA, in rtl8180_init_hw()
866 priv->tx_ring[1].dma); in rtl8180_init_hw()
867 rtl818x_iowrite32(priv, &priv->map->TLPDA, in rtl8180_init_hw()
868 priv->tx_ring[0].dma); in rtl8180_init_hw()
870 rtl818x_iowrite32(priv, &priv->map->TBDA, in rtl8180_init_hw()
871 priv->tx_ring[4].dma); in rtl8180_init_hw()
872 rtl818x_iowrite32(priv, &priv->map->TVODA, in rtl8180_init_hw()
873 priv->tx_ring[0].dma); in rtl8180_init_hw()
874 rtl818x_iowrite32(priv, &priv->map->TVIDA, in rtl8180_init_hw()
875 priv->tx_ring[1].dma); in rtl8180_init_hw()
876 rtl818x_iowrite32(priv, &priv->map->TBEDA, in rtl8180_init_hw()
877 priv->tx_ring[2].dma); in rtl8180_init_hw()
878 rtl818x_iowrite32(priv, &priv->map->TBKDA, in rtl8180_init_hw()
879 priv->tx_ring[3].dma); in rtl8180_init_hw()
883 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); in rtl8180_init_hw()
884 reg = rtl818x_ioread8(priv, &priv->map->CONFIG2); in rtl8180_init_hw()
885 rtl818x_iowrite8(priv, &priv->map->CONFIG2, reg & ~(1 << 3)); in rtl8180_init_hw()
886 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8185) { in rtl8180_init_hw()
887 reg = rtl818x_ioread8(priv, &priv->map->CONFIG2); in rtl8180_init_hw()
888 rtl818x_iowrite8(priv, &priv->map->CONFIG2, reg | (1 << 4)); in rtl8180_init_hw()
890 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); in rtl8180_init_hw()
896 rtl818x_iowrite32(priv, &priv->map->INT_TIMEOUT, 0); in rtl8180_init_hw()
898 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_init_hw()
899 rtl818x_iowrite8(priv, &priv->map->WPA_CONF, 0); in rtl8180_init_hw()
900 rtl818x_iowrite8(priv, &priv->map->RATE_FALLBACK, 0); in rtl8180_init_hw()
902 rtl818x_iowrite8(priv, &priv->map->SECURITY, 0); in rtl8180_init_hw()
904 rtl818x_iowrite8(priv, &priv->map->PHY_DELAY, 0x6); in rtl8180_init_hw()
905 rtl818x_iowrite8(priv, &priv->map->CARRIER_SENSE_COUNTER, 0x4C); in rtl8180_init_hw()
908 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8185) { in rtl8180_init_hw()
910 reg = rtl818x_ioread8(priv, &priv->map->GP_ENABLE); in rtl8180_init_hw()
911 rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, reg & ~(1 << 6)); in rtl8180_init_hw()
912 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); in rtl8180_init_hw()
913 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); in rtl8180_init_hw()
914 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg | (1 << 2)); in rtl8180_init_hw()
915 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); in rtl8180_init_hw()
916 /* fix eccessive IFS after CTS-to-self */ in rtl8180_init_hw()
917 if (priv->map_pio) { in rtl8180_init_hw()
920 reg = rtl818x_ioread8(priv, &priv->map->PGSELECT); in rtl8180_init_hw()
921 rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg | 1); in rtl8180_init_hw()
923 rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg); in rtl8180_init_hw()
928 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_init_hw()
935 rtl818x_iowrite8(priv, &priv->map->TPPOLL_STOP, in rtl8180_init_hw()
938 rtl818x_iowrite8(priv, &priv->map->ACM_CONTROL, 0x00); in rtl8180_init_hw()
939 rtl818x_iowrite16(priv, &priv->map->TID_AC_MAP, 0xFA50); in rtl8180_init_hw()
941 rtl818x_iowrite16(priv, &priv->map->INT_MIG, 0); in rtl8180_init_hw()
954 rtl818x_iowrite8(priv, &priv->map->CONFIG5, in rtl8180_init_hw()
955 rtl818x_ioread8(priv, &priv->map->CONFIG5) & 0x7F); in rtl8180_init_hw()
958 rtl818x_iowrite8(priv, &priv->map->PGSELECT, in rtl8180_init_hw()
959 rtl818x_ioread8(priv, &priv->map->PGSELECT) | 0x08); in rtl8180_init_hw()
961 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, 0x0480); in rtl8180_init_hw()
962 rtl818x_iowrite16(priv, &priv->map->RFPinsEnable, 0x1BFF); in rtl8180_init_hw()
963 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0x2488); in rtl8180_init_hw()
965 rtl818x_iowrite32(priv, &priv->map->RF_TIMING, 0x4003); in rtl8180_init_hw()
968 * this reg by doing byte-wide accesses. in rtl8180_init_hw()
971 reg32 = rtl818x_ioread32(priv, &priv->map->RF_PARA); in rtl8180_init_hw()
974 rtl818x_iowrite32(priv, &priv->map->RF_PARA, reg32); in rtl8180_init_hw()
977 rtl818x_iowrite8(priv, &priv->map->TX_DMA_POLLING, in rtl8180_init_hw()
980 priv->rf->init(dev); in rtl8180_init_hw()
988 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_init_hw()
993 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_init_hw()
995 priv->antenna_diversity_default, in rtl8180_init_hw()
996 priv->antenna_diversity_en); in rtl8180_init_hw()
1002 struct rtl8180_priv *priv = dev->priv; in rtl8180_init_rx_ring()
1006 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_init_rx_ring()
1007 priv->rx_ring_sz = sizeof(struct rtl8187se_rx_desc); in rtl8180_init_rx_ring()
1009 priv->rx_ring_sz = sizeof(struct rtl8180_rx_desc); in rtl8180_init_rx_ring()
1011 priv->rx_ring = dma_alloc_coherent(&priv->pdev->dev, in rtl8180_init_rx_ring()
1012 priv->rx_ring_sz * 32, in rtl8180_init_rx_ring()
1013 &priv->rx_ring_dma, GFP_KERNEL); in rtl8180_init_rx_ring()
1014 if (!priv->rx_ring || (unsigned long)priv->rx_ring & 0xFF) { in rtl8180_init_rx_ring()
1015 wiphy_err(dev->wiphy, "Cannot allocate RX ring\n"); in rtl8180_init_rx_ring()
1016 return -ENOMEM; in rtl8180_init_rx_ring()
1019 priv->rx_idx = 0; in rtl8180_init_rx_ring()
1024 entry = priv->rx_ring + priv->rx_ring_sz*i; in rtl8180_init_rx_ring()
1026 dma_free_coherent(&priv->pdev->dev, in rtl8180_init_rx_ring()
1027 priv->rx_ring_sz * 32, in rtl8180_init_rx_ring()
1028 priv->rx_ring, priv->rx_ring_dma); in rtl8180_init_rx_ring()
1029 wiphy_err(dev->wiphy, "Cannot allocate RX skb\n"); in rtl8180_init_rx_ring()
1030 return -ENOMEM; in rtl8180_init_rx_ring()
1032 priv->rx_buf[i] = skb; in rtl8180_init_rx_ring()
1033 mapping = (dma_addr_t *)skb->cb; in rtl8180_init_rx_ring()
1034 *mapping = dma_map_single(&priv->pdev->dev, in rtl8180_init_rx_ring()
1038 if (dma_mapping_error(&priv->pdev->dev, *mapping)) { in rtl8180_init_rx_ring()
1040 dma_free_coherent(&priv->pdev->dev, in rtl8180_init_rx_ring()
1041 priv->rx_ring_sz * 32, in rtl8180_init_rx_ring()
1042 priv->rx_ring, priv->rx_ring_dma); in rtl8180_init_rx_ring()
1043 wiphy_err(dev->wiphy, "Cannot map DMA for RX skb\n"); in rtl8180_init_rx_ring()
1044 return -ENOMEM; in rtl8180_init_rx_ring()
1047 entry->rx_buf = cpu_to_le32(*mapping); in rtl8180_init_rx_ring()
1048 entry->flags = cpu_to_le32(RTL818X_RX_DESC_FLAG_OWN | in rtl8180_init_rx_ring()
1051 entry->flags |= cpu_to_le32(RTL818X_RX_DESC_FLAG_EOR); in rtl8180_init_rx_ring()
1057 struct rtl8180_priv *priv = dev->priv; in rtl8180_free_rx_ring()
1061 struct sk_buff *skb = priv->rx_buf[i]; in rtl8180_free_rx_ring()
1065 dma_unmap_single(&priv->pdev->dev, *((dma_addr_t *)skb->cb), in rtl8180_free_rx_ring()
1070 dma_free_coherent(&priv->pdev->dev, priv->rx_ring_sz * 32, in rtl8180_free_rx_ring()
1071 priv->rx_ring, priv->rx_ring_dma); in rtl8180_free_rx_ring()
1072 priv->rx_ring = NULL; in rtl8180_free_rx_ring()
1078 struct rtl8180_priv *priv = dev->priv; in rtl8180_init_tx_ring()
1083 ring = dma_alloc_coherent(&priv->pdev->dev, sizeof(*ring) * entries, in rtl8180_init_tx_ring()
1086 wiphy_err(dev->wiphy, "Cannot allocate TX ring (prio = %d)\n", in rtl8180_init_tx_ring()
1088 return -ENOMEM; in rtl8180_init_tx_ring()
1091 priv->tx_ring[prio].desc = ring; in rtl8180_init_tx_ring()
1092 priv->tx_ring[prio].dma = dma; in rtl8180_init_tx_ring()
1093 priv->tx_ring[prio].idx = 0; in rtl8180_init_tx_ring()
1094 priv->tx_ring[prio].entries = entries; in rtl8180_init_tx_ring()
1095 skb_queue_head_init(&priv->tx_ring[prio].queue); in rtl8180_init_tx_ring()
1106 struct rtl8180_priv *priv = dev->priv; in rtl8180_free_tx_ring()
1107 struct rtl8180_tx_ring *ring = &priv->tx_ring[prio]; in rtl8180_free_tx_ring()
1109 while (skb_queue_len(&ring->queue)) { in rtl8180_free_tx_ring()
1110 struct rtl8180_tx_desc *entry = &ring->desc[ring->idx]; in rtl8180_free_tx_ring()
1111 struct sk_buff *skb = __skb_dequeue(&ring->queue); in rtl8180_free_tx_ring()
1113 dma_unmap_single(&priv->pdev->dev, le32_to_cpu(entry->tx_buf), in rtl8180_free_tx_ring()
1114 skb->len, DMA_TO_DEVICE); in rtl8180_free_tx_ring()
1116 ring->idx = (ring->idx + 1) % ring->entries; in rtl8180_free_tx_ring()
1119 dma_free_coherent(&priv->pdev->dev, in rtl8180_free_tx_ring()
1120 sizeof(*ring->desc) * ring->entries, ring->desc, in rtl8180_free_tx_ring()
1121 ring->dma); in rtl8180_free_tx_ring()
1122 ring->desc = NULL; in rtl8180_free_tx_ring()
1127 struct rtl8180_priv *priv = dev->priv; in rtl8180_start()
1135 for (i = 0; i < (dev->queues + 1); i++) in rtl8180_start()
1143 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_start()
1144 ret = request_irq(priv->pdev->irq, rtl8187se_interrupt, in rtl8180_start()
1147 ret = request_irq(priv->pdev->irq, rtl8180_interrupt, in rtl8180_start()
1152 wiphy_err(dev->wiphy, "failed to register IRQ handler\n"); in rtl8180_start()
1161 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_start()
1162 rtl818x_iowrite32(priv, &priv->map->MAR[0], ~0); in rtl8180_start()
1163 rtl818x_iowrite32(priv, &priv->map->MAR[1], ~0); in rtl8180_start()
1174 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8185) in rtl8180_start()
1176 else if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_start()
1177 reg |= (priv->rfparam & RF_PARAM_CARRIERSENSE1) in rtl8180_start()
1179 reg |= (priv->rfparam & RF_PARAM_CARRIERSENSE2) in rtl8180_start()
1185 priv->rx_conf = reg; in rtl8180_start()
1186 rtl818x_iowrite32(priv, &priv->map->RX_CONF, reg); in rtl8180_start()
1188 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_start()
1189 reg = rtl818x_ioread8(priv, &priv->map->CW_CONF); in rtl8180_start()
1191 /* CW is not on per-packet basis. in rtl8180_start()
1196 /* retry limit IS on per-packet basis. in rtl8180_start()
1197 * the short and long retry limit in TX_CONF in rtl8180_start()
1201 rtl818x_iowrite8(priv, &priv->map->CW_CONF, reg); in rtl8180_start()
1203 reg = rtl818x_ioread8(priv, &priv->map->TX_AGC_CTL); in rtl8180_start()
1204 /* TX antenna and TX gain are not on per-packet basis. in rtl8180_start()
1211 rtl818x_iowrite8(priv, &priv->map->TX_AGC_CTL, reg); in rtl8180_start()
1214 rtl818x_iowrite8(priv, (u8 __iomem *)priv->map + 0xec, 0x3f); in rtl8180_start()
1217 reg = rtl818x_ioread32(priv, &priv->map->TX_CONF); in rtl8180_start()
1221 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_start()
1224 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_start()
1234 rtl818x_iowrite32(priv, &priv->map->TX_CONF, reg); in rtl8180_start()
1236 reg = rtl818x_ioread8(priv, &priv->map->CMD); in rtl8180_start()
1239 rtl818x_iowrite8(priv, &priv->map->CMD, reg); in rtl8180_start()
1245 for (i = 0; i < (dev->queues + 1); i++) in rtl8180_start()
1246 if (priv->tx_ring[i].desc) in rtl8180_start()
1254 struct rtl8180_priv *priv = dev->priv; in rtl8180_stop()
1260 reg = rtl818x_ioread8(priv, &priv->map->CMD); in rtl8180_stop()
1263 rtl818x_iowrite8(priv, &priv->map->CMD, reg); in rtl8180_stop()
1265 priv->rf->stop(dev); in rtl8180_stop()
1267 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); in rtl8180_stop()
1268 reg = rtl818x_ioread8(priv, &priv->map->CONFIG4); in rtl8180_stop()
1269 rtl818x_iowrite8(priv, &priv->map->CONFIG4, reg | RTL818X_CONFIG4_VCOOFF); in rtl8180_stop()
1270 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); in rtl8180_stop()
1272 free_irq(priv->pdev->irq, dev); in rtl8180_stop()
1275 for (i = 0; i < (dev->queues + 1); i++) in rtl8180_stop()
1282 struct rtl8180_priv *priv = dev->priv; in rtl8180_get_tsf()
1284 return rtl818x_ioread32(priv, &priv->map->TSFT[0]) | in rtl8180_get_tsf()
1285 (u64)(rtl818x_ioread32(priv, &priv->map->TSFT[1])) << 32; in rtl8180_get_tsf()
1294 struct ieee80211_hw *dev = vif_priv->dev; in rtl8180_beacon_work()
1311 mgmt = (struct ieee80211_mgmt *)skb->data; in rtl8180_beacon_work()
1312 mgmt->u.beacon.timestamp = cpu_to_le64(rtl8180_get_tsf(dev, vif)); in rtl8180_beacon_work()
1324 schedule_delayed_work(&vif_priv->beacon_work, in rtl8180_beacon_work()
1325 usecs_to_jiffies(1024 * vif->bss_conf.beacon_int)); in rtl8180_beacon_work()
1331 struct rtl8180_priv *priv = dev->priv; in rtl8180_add_interface()
1337 if (priv->vif) in rtl8180_add_interface()
1338 return -EBUSY; in rtl8180_add_interface()
1340 switch (vif->type) { in rtl8180_add_interface()
1345 return -EOPNOTSUPP; in rtl8180_add_interface()
1348 priv->vif = vif; in rtl8180_add_interface()
1351 vif_priv = (struct rtl8180_vif *)&vif->drv_priv; in rtl8180_add_interface()
1352 vif_priv->dev = dev; in rtl8180_add_interface()
1353 INIT_DELAYED_WORK(&vif_priv->beacon_work, rtl8180_beacon_work); in rtl8180_add_interface()
1354 vif_priv->enable_beacon = false; in rtl8180_add_interface()
1356 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); in rtl8180_add_interface()
1357 rtl818x_iowrite32(priv, (__le32 __iomem *)&priv->map->MAC[0], in rtl8180_add_interface()
1358 le32_to_cpu(*(__le32 *)vif->addr)); in rtl8180_add_interface()
1359 rtl818x_iowrite16(priv, (__le16 __iomem *)&priv->map->MAC[4], in rtl8180_add_interface()
1360 le16_to_cpu(*(__le16 *)(vif->addr + 4))); in rtl8180_add_interface()
1361 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); in rtl8180_add_interface()
1369 struct rtl8180_priv *priv = dev->priv; in rtl8180_remove_interface()
1370 priv->vif = NULL; in rtl8180_remove_interface()
1375 struct rtl8180_priv *priv = dev->priv; in rtl8180_config()
1376 struct ieee80211_conf *conf = &dev->conf; in rtl8180_config()
1378 priv->rf->set_chan(dev, conf); in rtl8180_config()
1386 struct rtl8180_priv *priv = dev->priv; in rtl8187se_conf_ac_parm()
1395 params = &priv->queue_param[queue]; in rtl8187se_conf_ac_parm()
1397 cw_min = fls(params->cw_min); in rtl8187se_conf_ac_parm()
1398 cw_max = fls(params->cw_max); in rtl8187se_conf_ac_parm()
1400 aifs = 10 + params->aifs * priv->slot_time; in rtl8187se_conf_ac_parm()
1403 txop = params->txop; in rtl8187se_conf_ac_parm()
1412 rtl818x_iowrite32(priv, &priv->map->AC_BK_PARAM, ac_param); in rtl8187se_conf_ac_parm()
1415 rtl818x_iowrite32(priv, &priv->map->AC_BE_PARAM, ac_param); in rtl8187se_conf_ac_parm()
1418 rtl818x_iowrite32(priv, &priv->map->AC_VI_PARAM, ac_param); in rtl8187se_conf_ac_parm()
1421 rtl818x_iowrite32(priv, &priv->map->AC_VO_PARAM, ac_param); in rtl8187se_conf_ac_parm()
1431 struct rtl8180_priv *priv = dev->priv; in rtl8180_conf_tx()
1435 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_conf_tx()
1438 cw_min = fls(params->cw_min); in rtl8180_conf_tx()
1439 cw_max = fls(params->cw_max); in rtl8180_conf_tx()
1441 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_conf_tx()
1442 priv->queue_param[queue] = *params; in rtl8180_conf_tx()
1445 rtl818x_iowrite8(priv, &priv->map->CW_VAL, in rtl8180_conf_tx()
1453 struct rtl8180_priv *priv = dev->priv; in rtl8180_conf_erp()
1459 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_conf_erp()
1468 if (info->use_short_slot) in rtl8180_conf_erp()
1469 priv->slot_time = 9; in rtl8180_conf_erp()
1471 priv->slot_time = 20; in rtl8180_conf_erp()
1474 difs = 10 + 2 * priv->slot_time; in rtl8180_conf_erp()
1475 eifs = 10 + difs + priv->ack_time; in rtl8180_conf_erp()
1481 rtl818x_iowrite8(priv, &priv->map->SLOT, priv->slot_time); in rtl8180_conf_erp()
1482 rtl818x_iowrite8(priv, &priv->map->SIFS, sifs); in rtl8180_conf_erp()
1483 rtl818x_iowrite8(priv, &priv->map->DIFS, difs); in rtl8180_conf_erp()
1486 rtl818x_iowrite8(priv, &priv->map->CARRIER_SENSE_COUNTER, hw_eifs); in rtl8180_conf_erp()
1488 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_conf_erp()
1489 rtl818x_iowrite8(priv, &priv->map->EIFS_8187SE, hw_eifs); in rtl8180_conf_erp()
1490 else if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8185) { in rtl8180_conf_erp()
1495 hw_eifs = DIV_ROUND_UP(eifs - difs, 4); in rtl8180_conf_erp()
1497 rtl818x_iowrite8(priv, &priv->map->EIFS, hw_eifs); in rtl8180_conf_erp()
1506 struct rtl8180_priv *priv = dev->priv; in rtl8180_bss_info_changed()
1511 vif_priv = (struct rtl8180_vif *)&vif->drv_priv; in rtl8180_bss_info_changed()
1514 rtl818x_iowrite16(priv, (__le16 __iomem *)&priv->map->BSSID[0], in rtl8180_bss_info_changed()
1515 le16_to_cpu(*(__le16 *)info->bssid)); in rtl8180_bss_info_changed()
1516 rtl818x_iowrite32(priv, (__le32 __iomem *)&priv->map->BSSID[2], in rtl8180_bss_info_changed()
1517 le32_to_cpu(*(__le32 *)(info->bssid + 2))); in rtl8180_bss_info_changed()
1519 if (is_valid_ether_addr(info->bssid)) { in rtl8180_bss_info_changed()
1520 if (vif->type == NL80211_IFTYPE_ADHOC) in rtl8180_bss_info_changed()
1527 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_bss_info_changed()
1530 rtl818x_iowrite8(priv, &priv->map->MSR, reg); in rtl8180_bss_info_changed()
1534 rtl8180_conf_basic_rates(dev, info->basic_rates); in rtl8180_bss_info_changed()
1540 * Since mac80211 include SIFS time we remove it (-10) in rtl8180_bss_info_changed()
1542 priv->ack_time = in rtl8180_bss_info_changed()
1544 priv->vif, in rtl8180_bss_info_changed()
1546 &priv->rates[0])) - 10; in rtl8180_bss_info_changed()
1555 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_bss_info_changed()
1562 vif_priv->enable_beacon = info->enable_beacon; in rtl8180_bss_info_changed()
1565 cancel_delayed_work_sync(&vif_priv->beacon_work); in rtl8180_bss_info_changed()
1566 if (vif_priv->enable_beacon) in rtl8180_bss_info_changed()
1567 schedule_work(&vif_priv->beacon_work.work); in rtl8180_bss_info_changed()
1582 struct rtl8180_priv *priv = dev->priv; in rtl8180_configure_filter()
1585 priv->rx_conf ^= RTL818X_RX_CONF_FCS; in rtl8180_configure_filter()
1587 priv->rx_conf ^= RTL818X_RX_CONF_CTRL; in rtl8180_configure_filter()
1589 priv->rx_conf ^= RTL818X_RX_CONF_MONITOR; in rtl8180_configure_filter()
1591 priv->rx_conf |= RTL818X_RX_CONF_MULTICAST; in rtl8180_configure_filter()
1593 priv->rx_conf &= ~RTL818X_RX_CONF_MULTICAST; in rtl8180_configure_filter()
1597 if (priv->rx_conf & RTL818X_RX_CONF_FCS) in rtl8180_configure_filter()
1599 if (priv->rx_conf & RTL818X_RX_CONF_CTRL) in rtl8180_configure_filter()
1601 if (priv->rx_conf & RTL818X_RX_CONF_MONITOR) in rtl8180_configure_filter()
1603 if (priv->rx_conf & RTL818X_RX_CONF_MULTICAST) in rtl8180_configure_filter()
1606 rtl818x_iowrite32(priv, &priv->map->RX_CONF, priv->rx_conf); in rtl8180_configure_filter()
1630 struct rtl8180_priv *priv = eeprom->data; in rtl8180_eeprom_register_read()
1631 u8 reg = rtl818x_ioread8(priv, &priv->map->EEPROM_CMD); in rtl8180_eeprom_register_read()
1633 eeprom->reg_data_in = reg & RTL818X_EEPROM_CMD_WRITE; in rtl8180_eeprom_register_read()
1634 eeprom->reg_data_out = reg & RTL818X_EEPROM_CMD_READ; in rtl8180_eeprom_register_read()
1635 eeprom->reg_data_clock = reg & RTL818X_EEPROM_CMD_CK; in rtl8180_eeprom_register_read()
1636 eeprom->reg_chip_select = reg & RTL818X_EEPROM_CMD_CS; in rtl8180_eeprom_register_read()
1641 struct rtl8180_priv *priv = eeprom->data; in rtl8180_eeprom_register_write()
1644 if (eeprom->reg_data_in) in rtl8180_eeprom_register_write()
1646 if (eeprom->reg_data_out) in rtl8180_eeprom_register_write()
1648 if (eeprom->reg_data_clock) in rtl8180_eeprom_register_write()
1650 if (eeprom->reg_chip_select) in rtl8180_eeprom_register_write()
1653 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, reg); in rtl8180_eeprom_register_write()
1654 rtl818x_ioread8(priv, &priv->map->EEPROM_CMD); in rtl8180_eeprom_register_write()
1668 if (rtl818x_ioread32(priv, &priv->map->RX_CONF) & (1 << 6)) in rtl8180_eeprom_read()
1673 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, in rtl8180_eeprom_read()
1675 rtl818x_ioread8(priv, &priv->map->EEPROM_CMD); in rtl8180_eeprom_read()
1680 priv->rf_type = eeprom_val; in rtl8180_eeprom_read()
1683 priv->csthreshold = eeprom_val >> 8; in rtl8180_eeprom_read()
1685 eeprom_93cx6_multiread(&eeprom, 0x7, (__le16 *)priv->mac_addr, 3); in rtl8180_eeprom_read()
1687 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_eeprom_read()
1697 priv->channels[i].hw_value = txpwr & 0xFF; in rtl8180_eeprom_read()
1698 priv->channels[i + 1].hw_value = txpwr >> 8; in rtl8180_eeprom_read()
1702 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_eeprom_read()
1706 priv->channels[i].hw_value |= (txpwr & 0xFF) << 8; in rtl8180_eeprom_read()
1707 priv->channels[i + 1].hw_value |= txpwr & 0xFF00; in rtl8180_eeprom_read()
1711 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_eeprom_read()
1714 priv->anaparam = le32_to_cpu(anaparam); in rtl8180_eeprom_read()
1715 eeprom_93cx6_read(&eeprom, 0x19, &priv->rfparam); in rtl8180_eeprom_read()
1718 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_eeprom_read()
1720 priv->antenna_diversity_en = !!(eeprom_val & 0x100); in rtl8180_eeprom_read()
1721 priv->antenna_diversity_default = (eeprom_val & 0xC00) == 0x400; in rtl8180_eeprom_read()
1724 priv->xtal_out = eeprom_val & 0xF; in rtl8180_eeprom_read()
1725 priv->xtal_in = (eeprom_val & 0xF0) >> 4; in rtl8180_eeprom_read()
1726 priv->xtal_cal = !!(eeprom_val & 0x1000); in rtl8180_eeprom_read()
1727 priv->thermal_meter_val = (eeprom_val & 0xF00) >> 8; in rtl8180_eeprom_read()
1728 priv->thermal_meter_en = !!(eeprom_val & 0x2000); in rtl8180_eeprom_read()
1731 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, in rtl8180_eeprom_read()
1767 err = -ENOMEM; in rtl8180_probe()
1771 if ((err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) || in rtl8180_probe()
1772 (err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)))) { in rtl8180_probe()
1782 printk(KERN_ERR "%s (rtl8180): ieee80211 alloc failed\n", in rtl8180_probe()
1784 err = -ENOMEM; in rtl8180_probe()
1788 priv = dev->priv; in rtl8180_probe()
1789 priv->pdev = pdev; in rtl8180_probe()
1791 dev->max_rates = 1; in rtl8180_probe()
1792 SET_IEEE80211_DEV(dev, &pdev->dev); in rtl8180_probe()
1795 priv->map_pio = false; in rtl8180_probe()
1796 priv->map = pci_iomap(pdev, 1, mem_len); in rtl8180_probe()
1797 if (!priv->map) { in rtl8180_probe()
1798 priv->map = pci_iomap(pdev, 0, io_len); in rtl8180_probe()
1799 priv->map_pio = true; in rtl8180_probe()
1802 if (!priv->map) { in rtl8180_probe()
1803 dev_err(&pdev->dev, "Cannot map device memory/PIO\n"); in rtl8180_probe()
1804 err = -ENOMEM; in rtl8180_probe()
1808 BUILD_BUG_ON(sizeof(priv->channels) != sizeof(rtl818x_channels)); in rtl8180_probe()
1809 BUILD_BUG_ON(sizeof(priv->rates) != sizeof(rtl818x_rates)); in rtl8180_probe()
1811 memcpy(priv->channels, rtl818x_channels, sizeof(rtl818x_channels)); in rtl8180_probe()
1812 memcpy(priv->rates, rtl818x_rates, sizeof(rtl818x_rates)); in rtl8180_probe()
1814 priv->band.band = NL80211_BAND_2GHZ; in rtl8180_probe()
1815 priv->band.channels = priv->channels; in rtl8180_probe()
1816 priv->band.n_channels = ARRAY_SIZE(rtl818x_channels); in rtl8180_probe()
1817 priv->band.bitrates = priv->rates; in rtl8180_probe()
1818 priv->band.n_bitrates = 4; in rtl8180_probe()
1819 dev->wiphy->bands[NL80211_BAND_2GHZ] = &priv->band; in rtl8180_probe()
1824 dev->vif_data_size = sizeof(struct rtl8180_vif); in rtl8180_probe()
1825 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | in rtl8180_probe()
1827 dev->max_signal = 65; in rtl8180_probe()
1829 reg = rtl818x_ioread32(priv, &priv->map->TX_CONF); in rtl8180_probe()
1834 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8180; in rtl8180_probe()
1839 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8180; in rtl8180_probe()
1844 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8185; in rtl8180_probe()
1849 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8185; in rtl8180_probe()
1854 if (priv->map_pio) { in rtl8180_probe()
1855 dev_err(&pdev->dev, in rtl8180_probe()
1857 err = -ENOMEM; in rtl8180_probe()
1860 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8187SE; in rtl8180_probe()
1866 err = -ENODEV; in rtl8180_probe()
1877 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_probe()
1878 dev->queues = RTL8187SE_NR_TX_QUEUES - 1; in rtl8180_probe()
1880 dev->queues = RTL8180_NR_TX_QUEUES - 1; in rtl8180_probe()
1882 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_probe()
1883 priv->band.n_bitrates = ARRAY_SIZE(rtl818x_rates); in rtl8180_probe()
1887 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_probe()
1892 wiphy_ext_feature_set(dev->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); in rtl8180_probe()
1896 switch (priv->rf_type) { in rtl8180_probe()
1901 case 3: priv->rf = &sa2400_rf_ops; in rtl8180_probe()
1903 case 4: priv->rf = &max2820_rf_ops; in rtl8180_probe()
1905 case 5: priv->rf = &grf5101_rf_ops; in rtl8180_probe()
1908 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_probe()
1909 priv->rf = rtl8187se_detect_rf(dev); in rtl8180_probe()
1911 priv->rf = rtl8180_detect_rf(dev); in rtl8180_probe()
1918 pci_name(pdev), priv->rf_type); in rtl8180_probe()
1919 err = -ENODEV; in rtl8180_probe()
1923 if (!priv->rf) { in rtl8180_probe()
1926 err = -ENODEV; in rtl8180_probe()
1930 if (!is_valid_ether_addr(priv->mac_addr)) { in rtl8180_probe()
1933 eth_random_addr(priv->mac_addr); in rtl8180_probe()
1935 SET_IEEE80211_PERM_ADDR(dev, priv->mac_addr); in rtl8180_probe()
1937 spin_lock_init(&priv->lock); in rtl8180_probe()
1946 wiphy_info(dev->wiphy, "hwaddr %pm, %s + %s\n", in rtl8180_probe()
1947 priv->mac_addr, chip_name, priv->rf->name); in rtl8180_probe()
1952 pci_iounmap(pdev, priv->map); in rtl8180_probe()
1975 priv = dev->priv; in rtl8180_remove()
1977 pci_iounmap(pdev, priv->map); in rtl8180_remove()