Lines Matching +full:hi +full:- +full:fi
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...
126 * HI | 6 | 1
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.
171 * HI | 6 | 0
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()
474 ring = &priv->tx_ring[prio]; in rtl8180_tx()
476 mapping = dma_map_single(&priv->pdev->dev, skb->data, skb->len, in rtl8180_tx()
479 if (dma_mapping_error(&priv->pdev->dev, mapping)) { in rtl8180_tx()
481 dev_err(&priv->pdev->dev, "TX DMA mapping error\n"); in rtl8180_tx()
487 (ieee80211_get_tx_rate(dev, info)->hw_value << 24) | in rtl8180_tx()
488 skb->len; in rtl8180_tx()
490 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_tx()
494 rc_flags = info->control.rates[0].flags; in rtl8180_tx()
496 /* HW will perform RTS-CTS when only RTS flags is set. in rtl8180_tx()
497 * HW will perform CTS-to-self when both RTS and CTS flags are set. in rtl8180_tx()
498 * RTS rate and RTS duration will be used also for CTS-to-self. in rtl8180_tx()
502 tx_flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19; in rtl8180_tx()
503 rts_duration = ieee80211_rts_duration(dev, priv->vif, in rtl8180_tx()
504 skb->len, info); in rtl8180_tx()
507 tx_flags |= ieee80211_get_rts_cts_rate(dev, info)->hw_value << 19; in rtl8180_tx()
508 rts_duration = ieee80211_ctstoself_duration(dev, priv->vif, in rtl8180_tx()
509 skb->len, info); in rtl8180_tx()
512 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_tx()
515 plcp_len = DIV_ROUND_UP(16 * (skb->len + 4), in rtl8180_tx()
516 (ieee80211_get_tx_rate(dev, info)->bitrate * 2) / 10); in rtl8180_tx()
517 remainder = (16 * (skb->len + 4)) % in rtl8180_tx()
518 ((ieee80211_get_tx_rate(dev, info)->bitrate * 2) / 10); in rtl8180_tx()
523 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_tx()
528 duration = ieee80211_generic_frame_duration(dev, priv->vif, in rtl8180_tx()
529 NL80211_BAND_2GHZ, skb->len, in rtl8180_tx()
532 frame_duration = priv->ack_time + le16_to_cpu(duration); in rtl8180_tx()
535 spin_lock_irqsave(&priv->lock, flags); in rtl8180_tx()
537 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { in rtl8180_tx()
538 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) in rtl8180_tx()
539 priv->seqno += 0x10; in rtl8180_tx()
540 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); in rtl8180_tx()
541 hdr->seq_ctrl |= cpu_to_le16(priv->seqno); in rtl8180_tx()
544 idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; in rtl8180_tx()
545 entry = &ring->desc[idx]; in rtl8180_tx()
547 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_tx()
548 entry->frame_duration = cpu_to_le16(frame_duration); in rtl8180_tx()
549 entry->frame_len_se = cpu_to_le16(skb->len); in rtl8180_tx()
552 entry->flags3 = cpu_to_le16(1<<4); in rtl8180_tx()
554 entry->frame_len = cpu_to_le32(skb->len); in rtl8180_tx()
556 entry->rts_duration = rts_duration; in rtl8180_tx()
557 entry->plcp_len = cpu_to_le16(plcp_len); in rtl8180_tx()
558 entry->tx_buf = cpu_to_le32(mapping); in rtl8180_tx()
560 entry->retry_limit = info->control.rates[0].count - 1; in rtl8180_tx()
566 entry->flags = cpu_to_le32(tx_flags); in rtl8180_tx()
569 * to DMA the just-written data in rtl8180_tx()
573 __skb_queue_tail(&ring->queue, skb); in rtl8180_tx()
574 if (ring->entries - skb_queue_len(&ring->queue) < 2) in rtl8180_tx()
577 spin_unlock_irqrestore(&priv->lock, flags); in rtl8180_tx()
579 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_tx()
582 rtl818x_iowrite8(priv, &priv->map->TX_DMA_POLLING, in rtl8180_tx()
586 rtl818x_iowrite8(priv, &priv->map->TX_DMA_POLLING, in rtl8180_tx()
596 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, in rtl8180_set_anaparam3()
599 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); in rtl8180_set_anaparam3()
600 rtl818x_iowrite8(priv, &priv->map->CONFIG3, in rtl8180_set_anaparam3()
603 rtl818x_iowrite16(priv, &priv->map->ANAPARAM3, anaparam3); in rtl8180_set_anaparam3()
605 rtl818x_iowrite8(priv, &priv->map->CONFIG3, in rtl8180_set_anaparam3()
608 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, in rtl8180_set_anaparam3()
616 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, in rtl8180_set_anaparam2()
619 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); in rtl8180_set_anaparam2()
620 rtl818x_iowrite8(priv, &priv->map->CONFIG3, in rtl8180_set_anaparam2()
623 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2, anaparam2); in rtl8180_set_anaparam2()
625 rtl818x_iowrite8(priv, &priv->map->CONFIG3, in rtl8180_set_anaparam2()
628 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, in rtl8180_set_anaparam2()
636 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); in rtl8180_set_anaparam()
637 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); in rtl8180_set_anaparam()
638 rtl818x_iowrite8(priv, &priv->map->CONFIG3, in rtl8180_set_anaparam()
640 rtl818x_iowrite32(priv, &priv->map->ANAPARAM, anaparam); in rtl8180_set_anaparam()
641 rtl818x_iowrite8(priv, &priv->map->CONFIG3, in rtl8180_set_anaparam()
643 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); in rtl8180_set_anaparam()
648 struct rtl8180_priv *priv = dev->priv; in rtl8187se_mac_config()
658 reg = rtl818x_ioread8(priv, &priv->map->PHY_PR); in rtl8187se_mac_config()
659 rtl818x_iowrite8(priv, &priv->map->PHY_PR, reg | 0x04); in rtl8187se_mac_config()
663 /* AFE - default to power ON */ in rtl8187se_mac_config()
680 struct rtl8180_priv *priv = dev->priv; in rtl8187se_set_antenna_config()
685 rtl818x_iowrite8(priv, &priv->map->TX_ANTENNA, 0x00); in rtl8187se_set_antenna_config()
691 rtl818x_iowrite8(priv, &priv->map->TX_ANTENNA, 0x03); in rtl8187se_set_antenna_config()
699 rtl818x_iowrite8(priv, &priv->map->TX_ANTENNA, 0x00); in rtl8187se_set_antenna_config()
705 rtl818x_iowrite8(priv, &priv->map->TX_ANTENNA, 0x03); in rtl8187se_set_antenna_config()
712 /* priv->curr_ant = def_ant; */ in rtl8187se_set_antenna_config()
717 struct rtl8180_priv *priv = dev->priv; in rtl8180_int_enable()
719 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_int_enable()
720 rtl818x_iowrite32(priv, &priv->map->IMR, in rtl8180_int_enable()
729 rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0xFFFF); in rtl8180_int_enable()
735 struct rtl8180_priv *priv = dev->priv; in rtl8180_int_disable()
737 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_int_disable()
738 rtl818x_iowrite32(priv, &priv->map->IMR, 0); in rtl8180_int_disable()
740 rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0); in rtl8180_int_disable()
747 struct rtl8180_priv *priv = dev->priv; in rtl8180_conf_basic_rates()
763 switch (priv->chip_family) { in rtl8180_conf_basic_rates()
767 basic_max = fls(basic_mask) - 1; in rtl8180_conf_basic_rates()
768 reg = rtl818x_ioread16(priv, &priv->map->BRSR); in rtl8180_conf_basic_rates()
771 rtl818x_iowrite16(priv, &priv->map->BRSR, reg); in rtl8180_conf_basic_rates()
775 resp_max = fls(resp_mask) - 1; in rtl8180_conf_basic_rates()
776 resp_min = ffs(resp_mask) - 1; in rtl8180_conf_basic_rates()
778 rtl818x_iowrite16(priv, &priv->map->BRSR, basic_mask); in rtl8180_conf_basic_rates()
779 rtl818x_iowrite8(priv, &priv->map->RESP_RATE, (resp_max << 4) | in rtl8180_conf_basic_rates()
787 rtl818x_iowrite16(priv, &priv->map->BRSR_8187SE, resp_mask); in rtl8180_conf_basic_rates()
794 struct rtl8180_priv *priv = dev->priv; in rtl8180_config_cardbus()
798 reg8 = rtl818x_ioread8(priv, &priv->map->CONFIG3); in rtl8180_config_cardbus()
800 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg8); in rtl8180_config_cardbus()
802 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_config_cardbus()
805 reg16 = rtl818x_ioread16(priv, &priv->map->FEMR); in rtl8180_config_cardbus()
807 rtl818x_iowrite16(priv, &priv->map->FEMR, reg16); in rtl8180_config_cardbus()
814 struct rtl8180_priv *priv = dev->priv; in rtl8180_init_hw()
818 rtl818x_iowrite8(priv, &priv->map->CMD, 0); in rtl8180_init_hw()
819 rtl818x_ioread8(priv, &priv->map->CMD); in rtl8180_init_hw()
824 rtl818x_ioread8(priv, &priv->map->CMD); in rtl8180_init_hw()
826 reg = rtl818x_ioread8(priv, &priv->map->CMD); in rtl8180_init_hw()
829 rtl818x_iowrite8(priv, &priv->map->CMD, RTL818X_CMD_RESET); in rtl8180_init_hw()
830 rtl818x_ioread8(priv, &priv->map->CMD); in rtl8180_init_hw()
834 if (rtl818x_ioread8(priv, &priv->map->CMD) & RTL818X_CMD_RESET) { in rtl8180_init_hw()
835 wiphy_err(dev->wiphy, "reset timeout!\n"); in rtl8180_init_hw()
836 return -ETIMEDOUT; in rtl8180_init_hw()
839 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_LOAD); in rtl8180_init_hw()
840 rtl818x_ioread8(priv, &priv->map->CMD); in rtl8180_init_hw()
843 if (rtl818x_ioread8(priv, &priv->map->CONFIG3) & (1 << 3)) { in rtl8180_init_hw()
847 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_init_hw()
848 rtl818x_iowrite8(priv, &priv->map->MSR, RTL818X_MSR_ENEDCA); in rtl8180_init_hw()
850 rtl818x_iowrite8(priv, &priv->map->MSR, 0); in rtl8180_init_hw()
852 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_init_hw()
853 rtl8180_set_anaparam(priv, priv->anaparam); in rtl8180_init_hw()
855 rtl818x_iowrite32(priv, &priv->map->RDSAR, priv->rx_ring_dma); in rtl8180_init_hw()
860 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_init_hw()
861 rtl818x_iowrite32(priv, &priv->map->TBDA, in rtl8180_init_hw()
862 priv->tx_ring[1].dma); in rtl8180_init_hw()
863 rtl818x_iowrite32(priv, &priv->map->TLPDA, in rtl8180_init_hw()
864 priv->tx_ring[0].dma); in rtl8180_init_hw()
866 rtl818x_iowrite32(priv, &priv->map->TBDA, in rtl8180_init_hw()
867 priv->tx_ring[4].dma); in rtl8180_init_hw()
868 rtl818x_iowrite32(priv, &priv->map->TVODA, in rtl8180_init_hw()
869 priv->tx_ring[0].dma); in rtl8180_init_hw()
870 rtl818x_iowrite32(priv, &priv->map->TVIDA, in rtl8180_init_hw()
871 priv->tx_ring[1].dma); in rtl8180_init_hw()
872 rtl818x_iowrite32(priv, &priv->map->TBEDA, in rtl8180_init_hw()
873 priv->tx_ring[2].dma); in rtl8180_init_hw()
874 rtl818x_iowrite32(priv, &priv->map->TBKDA, in rtl8180_init_hw()
875 priv->tx_ring[3].dma); in rtl8180_init_hw()
879 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); in rtl8180_init_hw()
880 reg = rtl818x_ioread8(priv, &priv->map->CONFIG2); in rtl8180_init_hw()
881 rtl818x_iowrite8(priv, &priv->map->CONFIG2, reg & ~(1 << 3)); in rtl8180_init_hw()
882 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8185) { in rtl8180_init_hw()
883 reg = rtl818x_ioread8(priv, &priv->map->CONFIG2); in rtl8180_init_hw()
884 rtl818x_iowrite8(priv, &priv->map->CONFIG2, reg | (1 << 4)); in rtl8180_init_hw()
886 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); in rtl8180_init_hw()
892 rtl818x_iowrite32(priv, &priv->map->INT_TIMEOUT, 0); in rtl8180_init_hw()
894 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_init_hw()
895 rtl818x_iowrite8(priv, &priv->map->WPA_CONF, 0); in rtl8180_init_hw()
896 rtl818x_iowrite8(priv, &priv->map->RATE_FALLBACK, 0); in rtl8180_init_hw()
898 rtl818x_iowrite8(priv, &priv->map->SECURITY, 0); in rtl8180_init_hw()
900 rtl818x_iowrite8(priv, &priv->map->PHY_DELAY, 0x6); in rtl8180_init_hw()
901 rtl818x_iowrite8(priv, &priv->map->CARRIER_SENSE_COUNTER, 0x4C); in rtl8180_init_hw()
904 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8185) { in rtl8180_init_hw()
906 reg = rtl818x_ioread8(priv, &priv->map->GP_ENABLE); in rtl8180_init_hw()
907 rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, reg & ~(1 << 6)); in rtl8180_init_hw()
908 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); in rtl8180_init_hw()
909 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); in rtl8180_init_hw()
910 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg | (1 << 2)); in rtl8180_init_hw()
911 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); in rtl8180_init_hw()
912 /* fix eccessive IFS after CTS-to-self */ in rtl8180_init_hw()
913 if (priv->map_pio) { in rtl8180_init_hw()
916 reg = rtl818x_ioread8(priv, &priv->map->PGSELECT); in rtl8180_init_hw()
917 rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg | 1); in rtl8180_init_hw()
919 rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg); in rtl8180_init_hw()
924 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_init_hw()
931 rtl818x_iowrite8(priv, &priv->map->TPPOLL_STOP, in rtl8180_init_hw()
934 rtl818x_iowrite8(priv, &priv->map->ACM_CONTROL, 0x00); in rtl8180_init_hw()
935 rtl818x_iowrite16(priv, &priv->map->TID_AC_MAP, 0xFA50); in rtl8180_init_hw()
937 rtl818x_iowrite16(priv, &priv->map->INT_MIG, 0); in rtl8180_init_hw()
950 rtl818x_iowrite8(priv, &priv->map->CONFIG5, in rtl8180_init_hw()
951 rtl818x_ioread8(priv, &priv->map->CONFIG5) & 0x7F); in rtl8180_init_hw()
954 rtl818x_iowrite8(priv, &priv->map->PGSELECT, in rtl8180_init_hw()
955 rtl818x_ioread8(priv, &priv->map->PGSELECT) | 0x08); in rtl8180_init_hw()
957 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, 0x0480); in rtl8180_init_hw()
958 rtl818x_iowrite16(priv, &priv->map->RFPinsEnable, 0x1BFF); in rtl8180_init_hw()
959 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0x2488); in rtl8180_init_hw()
961 rtl818x_iowrite32(priv, &priv->map->RF_TIMING, 0x4003); in rtl8180_init_hw()
964 * this reg by doing byte-wide accesses. in rtl8180_init_hw()
967 reg32 = rtl818x_ioread32(priv, &priv->map->RF_PARA); in rtl8180_init_hw()
970 rtl818x_iowrite32(priv, &priv->map->RF_PARA, reg32); in rtl8180_init_hw()
973 rtl818x_iowrite8(priv, &priv->map->TX_DMA_POLLING, in rtl8180_init_hw()
976 priv->rf->init(dev); in rtl8180_init_hw()
984 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_init_hw()
989 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_init_hw()
991 priv->antenna_diversity_default, in rtl8180_init_hw()
992 priv->antenna_diversity_en); in rtl8180_init_hw()
998 struct rtl8180_priv *priv = dev->priv; in rtl8180_init_rx_ring()
1002 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_init_rx_ring()
1003 priv->rx_ring_sz = sizeof(struct rtl8187se_rx_desc); in rtl8180_init_rx_ring()
1005 priv->rx_ring_sz = sizeof(struct rtl8180_rx_desc); in rtl8180_init_rx_ring()
1007 priv->rx_ring = dma_alloc_coherent(&priv->pdev->dev, in rtl8180_init_rx_ring()
1008 priv->rx_ring_sz * 32, in rtl8180_init_rx_ring()
1009 &priv->rx_ring_dma, GFP_KERNEL); in rtl8180_init_rx_ring()
1010 if (!priv->rx_ring || (unsigned long)priv->rx_ring & 0xFF) { in rtl8180_init_rx_ring()
1011 wiphy_err(dev->wiphy, "Cannot allocate RX ring\n"); in rtl8180_init_rx_ring()
1012 return -ENOMEM; in rtl8180_init_rx_ring()
1015 priv->rx_idx = 0; in rtl8180_init_rx_ring()
1020 entry = priv->rx_ring + priv->rx_ring_sz*i; in rtl8180_init_rx_ring()
1022 dma_free_coherent(&priv->pdev->dev, in rtl8180_init_rx_ring()
1023 priv->rx_ring_sz * 32, in rtl8180_init_rx_ring()
1024 priv->rx_ring, priv->rx_ring_dma); in rtl8180_init_rx_ring()
1025 wiphy_err(dev->wiphy, "Cannot allocate RX skb\n"); in rtl8180_init_rx_ring()
1026 return -ENOMEM; in rtl8180_init_rx_ring()
1028 priv->rx_buf[i] = skb; in rtl8180_init_rx_ring()
1029 mapping = (dma_addr_t *)skb->cb; in rtl8180_init_rx_ring()
1030 *mapping = dma_map_single(&priv->pdev->dev, in rtl8180_init_rx_ring()
1034 if (dma_mapping_error(&priv->pdev->dev, *mapping)) { in rtl8180_init_rx_ring()
1036 dma_free_coherent(&priv->pdev->dev, in rtl8180_init_rx_ring()
1037 priv->rx_ring_sz * 32, in rtl8180_init_rx_ring()
1038 priv->rx_ring, priv->rx_ring_dma); in rtl8180_init_rx_ring()
1039 wiphy_err(dev->wiphy, "Cannot map DMA for RX skb\n"); in rtl8180_init_rx_ring()
1040 return -ENOMEM; in rtl8180_init_rx_ring()
1043 entry->rx_buf = cpu_to_le32(*mapping); in rtl8180_init_rx_ring()
1044 entry->flags = cpu_to_le32(RTL818X_RX_DESC_FLAG_OWN | in rtl8180_init_rx_ring()
1047 entry->flags |= cpu_to_le32(RTL818X_RX_DESC_FLAG_EOR); in rtl8180_init_rx_ring()
1053 struct rtl8180_priv *priv = dev->priv; in rtl8180_free_rx_ring()
1057 struct sk_buff *skb = priv->rx_buf[i]; in rtl8180_free_rx_ring()
1061 dma_unmap_single(&priv->pdev->dev, *((dma_addr_t *)skb->cb), in rtl8180_free_rx_ring()
1066 dma_free_coherent(&priv->pdev->dev, priv->rx_ring_sz * 32, in rtl8180_free_rx_ring()
1067 priv->rx_ring, priv->rx_ring_dma); in rtl8180_free_rx_ring()
1068 priv->rx_ring = NULL; in rtl8180_free_rx_ring()
1074 struct rtl8180_priv *priv = dev->priv; in rtl8180_init_tx_ring()
1079 ring = dma_alloc_coherent(&priv->pdev->dev, sizeof(*ring) * entries, in rtl8180_init_tx_ring()
1082 wiphy_err(dev->wiphy, "Cannot allocate TX ring (prio = %d)\n", in rtl8180_init_tx_ring()
1084 return -ENOMEM; in rtl8180_init_tx_ring()
1087 priv->tx_ring[prio].desc = ring; in rtl8180_init_tx_ring()
1088 priv->tx_ring[prio].dma = dma; in rtl8180_init_tx_ring()
1089 priv->tx_ring[prio].idx = 0; in rtl8180_init_tx_ring()
1090 priv->tx_ring[prio].entries = entries; in rtl8180_init_tx_ring()
1091 skb_queue_head_init(&priv->tx_ring[prio].queue); in rtl8180_init_tx_ring()
1102 struct rtl8180_priv *priv = dev->priv; in rtl8180_free_tx_ring()
1103 struct rtl8180_tx_ring *ring = &priv->tx_ring[prio]; in rtl8180_free_tx_ring()
1105 while (skb_queue_len(&ring->queue)) { in rtl8180_free_tx_ring()
1106 struct rtl8180_tx_desc *entry = &ring->desc[ring->idx]; in rtl8180_free_tx_ring()
1107 struct sk_buff *skb = __skb_dequeue(&ring->queue); in rtl8180_free_tx_ring()
1109 dma_unmap_single(&priv->pdev->dev, le32_to_cpu(entry->tx_buf), in rtl8180_free_tx_ring()
1110 skb->len, DMA_TO_DEVICE); in rtl8180_free_tx_ring()
1112 ring->idx = (ring->idx + 1) % ring->entries; in rtl8180_free_tx_ring()
1115 dma_free_coherent(&priv->pdev->dev, in rtl8180_free_tx_ring()
1116 sizeof(*ring->desc) * ring->entries, ring->desc, in rtl8180_free_tx_ring()
1117 ring->dma); in rtl8180_free_tx_ring()
1118 ring->desc = NULL; in rtl8180_free_tx_ring()
1123 struct rtl8180_priv *priv = dev->priv; in rtl8180_start()
1131 for (i = 0; i < (dev->queues + 1); i++) in rtl8180_start()
1139 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_start()
1140 ret = request_irq(priv->pdev->irq, rtl8187se_interrupt, in rtl8180_start()
1143 ret = request_irq(priv->pdev->irq, rtl8180_interrupt, in rtl8180_start()
1148 wiphy_err(dev->wiphy, "failed to register IRQ handler\n"); in rtl8180_start()
1157 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_start()
1158 rtl818x_iowrite32(priv, &priv->map->MAR[0], ~0); in rtl8180_start()
1159 rtl818x_iowrite32(priv, &priv->map->MAR[1], ~0); in rtl8180_start()
1170 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8185) in rtl8180_start()
1172 else if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_start()
1173 reg |= (priv->rfparam & RF_PARAM_CARRIERSENSE1) in rtl8180_start()
1175 reg |= (priv->rfparam & RF_PARAM_CARRIERSENSE2) in rtl8180_start()
1181 priv->rx_conf = reg; in rtl8180_start()
1182 rtl818x_iowrite32(priv, &priv->map->RX_CONF, reg); in rtl8180_start()
1184 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_start()
1185 reg = rtl818x_ioread8(priv, &priv->map->CW_CONF); in rtl8180_start()
1187 /* CW is not on per-packet basis. in rtl8180_start()
1192 /* retry limit IS on per-packet basis. in rtl8180_start()
1197 rtl818x_iowrite8(priv, &priv->map->CW_CONF, reg); in rtl8180_start()
1199 reg = rtl818x_ioread8(priv, &priv->map->TX_AGC_CTL); in rtl8180_start()
1200 /* TX antenna and TX gain are not on per-packet basis. in rtl8180_start()
1207 rtl818x_iowrite8(priv, &priv->map->TX_AGC_CTL, reg); in rtl8180_start()
1210 rtl818x_iowrite8(priv, (u8 __iomem *)priv->map + 0xec, 0x3f); in rtl8180_start()
1213 reg = rtl818x_ioread32(priv, &priv->map->TX_CONF); in rtl8180_start()
1217 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_start()
1220 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_start()
1230 rtl818x_iowrite32(priv, &priv->map->TX_CONF, reg); in rtl8180_start()
1232 reg = rtl818x_ioread8(priv, &priv->map->CMD); in rtl8180_start()
1235 rtl818x_iowrite8(priv, &priv->map->CMD, reg); in rtl8180_start()
1241 for (i = 0; i < (dev->queues + 1); i++) in rtl8180_start()
1242 if (priv->tx_ring[i].desc) in rtl8180_start()
1250 struct rtl8180_priv *priv = dev->priv; in rtl8180_stop()
1256 reg = rtl818x_ioread8(priv, &priv->map->CMD); in rtl8180_stop()
1259 rtl818x_iowrite8(priv, &priv->map->CMD, reg); in rtl8180_stop()
1261 priv->rf->stop(dev); in rtl8180_stop()
1263 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); in rtl8180_stop()
1264 reg = rtl818x_ioread8(priv, &priv->map->CONFIG4); in rtl8180_stop()
1265 rtl818x_iowrite8(priv, &priv->map->CONFIG4, reg | RTL818X_CONFIG4_VCOOFF); in rtl8180_stop()
1266 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); in rtl8180_stop()
1268 free_irq(priv->pdev->irq, dev); in rtl8180_stop()
1271 for (i = 0; i < (dev->queues + 1); i++) in rtl8180_stop()
1278 struct rtl8180_priv *priv = dev->priv; in rtl8180_get_tsf()
1280 return rtl818x_ioread32(priv, &priv->map->TSFT[0]) | in rtl8180_get_tsf()
1281 (u64)(rtl818x_ioread32(priv, &priv->map->TSFT[1])) << 32; in rtl8180_get_tsf()
1290 struct ieee80211_hw *dev = vif_priv->dev; in rtl8180_beacon_work()
1307 mgmt = (struct ieee80211_mgmt *)skb->data; in rtl8180_beacon_work()
1308 mgmt->u.beacon.timestamp = cpu_to_le64(rtl8180_get_tsf(dev, vif)); in rtl8180_beacon_work()
1320 schedule_delayed_work(&vif_priv->beacon_work, in rtl8180_beacon_work()
1321 usecs_to_jiffies(1024 * vif->bss_conf.beacon_int)); in rtl8180_beacon_work()
1327 struct rtl8180_priv *priv = dev->priv; in rtl8180_add_interface()
1333 if (priv->vif) in rtl8180_add_interface()
1334 return -EBUSY; in rtl8180_add_interface()
1336 switch (vif->type) { in rtl8180_add_interface()
1341 return -EOPNOTSUPP; in rtl8180_add_interface()
1344 priv->vif = vif; in rtl8180_add_interface()
1347 vif_priv = (struct rtl8180_vif *)&vif->drv_priv; in rtl8180_add_interface()
1348 vif_priv->dev = dev; in rtl8180_add_interface()
1349 INIT_DELAYED_WORK(&vif_priv->beacon_work, rtl8180_beacon_work); in rtl8180_add_interface()
1350 vif_priv->enable_beacon = false; in rtl8180_add_interface()
1352 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); in rtl8180_add_interface()
1353 rtl818x_iowrite32(priv, (__le32 __iomem *)&priv->map->MAC[0], in rtl8180_add_interface()
1354 le32_to_cpu(*(__le32 *)vif->addr)); in rtl8180_add_interface()
1355 rtl818x_iowrite16(priv, (__le16 __iomem *)&priv->map->MAC[4], in rtl8180_add_interface()
1356 le16_to_cpu(*(__le16 *)(vif->addr + 4))); in rtl8180_add_interface()
1357 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); in rtl8180_add_interface()
1365 struct rtl8180_priv *priv = dev->priv; in rtl8180_remove_interface()
1366 priv->vif = NULL; in rtl8180_remove_interface()
1371 struct rtl8180_priv *priv = dev->priv; in rtl8180_config()
1372 struct ieee80211_conf *conf = &dev->conf; in rtl8180_config()
1374 priv->rf->set_chan(dev, conf); in rtl8180_config()
1382 struct rtl8180_priv *priv = dev->priv; in rtl8187se_conf_ac_parm()
1391 params = &priv->queue_param[queue]; in rtl8187se_conf_ac_parm()
1393 cw_min = fls(params->cw_min); in rtl8187se_conf_ac_parm()
1394 cw_max = fls(params->cw_max); in rtl8187se_conf_ac_parm()
1396 aifs = 10 + params->aifs * priv->slot_time; in rtl8187se_conf_ac_parm()
1399 txop = params->txop; in rtl8187se_conf_ac_parm()
1408 rtl818x_iowrite32(priv, &priv->map->AC_BK_PARAM, ac_param); in rtl8187se_conf_ac_parm()
1411 rtl818x_iowrite32(priv, &priv->map->AC_BE_PARAM, ac_param); in rtl8187se_conf_ac_parm()
1414 rtl818x_iowrite32(priv, &priv->map->AC_VI_PARAM, ac_param); in rtl8187se_conf_ac_parm()
1417 rtl818x_iowrite32(priv, &priv->map->AC_VO_PARAM, ac_param); in rtl8187se_conf_ac_parm()
1426 struct rtl8180_priv *priv = dev->priv; in rtl8180_conf_tx()
1430 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_conf_tx()
1433 cw_min = fls(params->cw_min); in rtl8180_conf_tx()
1434 cw_max = fls(params->cw_max); in rtl8180_conf_tx()
1436 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_conf_tx()
1437 priv->queue_param[queue] = *params; in rtl8180_conf_tx()
1440 rtl818x_iowrite8(priv, &priv->map->CW_VAL, in rtl8180_conf_tx()
1448 struct rtl8180_priv *priv = dev->priv; in rtl8180_conf_erp()
1454 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_conf_erp()
1463 if (info->use_short_slot) in rtl8180_conf_erp()
1464 priv->slot_time = 9; in rtl8180_conf_erp()
1466 priv->slot_time = 20; in rtl8180_conf_erp()
1469 difs = 10 + 2 * priv->slot_time; in rtl8180_conf_erp()
1470 eifs = 10 + difs + priv->ack_time; in rtl8180_conf_erp()
1476 rtl818x_iowrite8(priv, &priv->map->SLOT, priv->slot_time); in rtl8180_conf_erp()
1477 rtl818x_iowrite8(priv, &priv->map->SIFS, sifs); in rtl8180_conf_erp()
1478 rtl818x_iowrite8(priv, &priv->map->DIFS, difs); in rtl8180_conf_erp()
1481 rtl818x_iowrite8(priv, &priv->map->CARRIER_SENSE_COUNTER, hw_eifs); in rtl8180_conf_erp()
1483 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_conf_erp()
1484 rtl818x_iowrite8(priv, &priv->map->EIFS_8187SE, hw_eifs); in rtl8180_conf_erp()
1485 else if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8185) { in rtl8180_conf_erp()
1490 hw_eifs = DIV_ROUND_UP(eifs - difs, 4); in rtl8180_conf_erp()
1492 rtl818x_iowrite8(priv, &priv->map->EIFS, hw_eifs); in rtl8180_conf_erp()
1501 struct rtl8180_priv *priv = dev->priv; in rtl8180_bss_info_changed()
1506 vif_priv = (struct rtl8180_vif *)&vif->drv_priv; in rtl8180_bss_info_changed()
1509 rtl818x_iowrite16(priv, (__le16 __iomem *)&priv->map->BSSID[0], in rtl8180_bss_info_changed()
1510 le16_to_cpu(*(__le16 *)info->bssid)); in rtl8180_bss_info_changed()
1511 rtl818x_iowrite32(priv, (__le32 __iomem *)&priv->map->BSSID[2], in rtl8180_bss_info_changed()
1512 le32_to_cpu(*(__le32 *)(info->bssid + 2))); in rtl8180_bss_info_changed()
1514 if (is_valid_ether_addr(info->bssid)) { in rtl8180_bss_info_changed()
1515 if (vif->type == NL80211_IFTYPE_ADHOC) in rtl8180_bss_info_changed()
1522 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_bss_info_changed()
1525 rtl818x_iowrite8(priv, &priv->map->MSR, reg); in rtl8180_bss_info_changed()
1529 rtl8180_conf_basic_rates(dev, info->basic_rates); in rtl8180_bss_info_changed()
1535 * Since mac80211 include SIFS time we remove it (-10) in rtl8180_bss_info_changed()
1537 priv->ack_time = in rtl8180_bss_info_changed()
1539 priv->vif, in rtl8180_bss_info_changed()
1541 &priv->rates[0])) - 10; in rtl8180_bss_info_changed()
1550 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_bss_info_changed()
1557 vif_priv->enable_beacon = info->enable_beacon; in rtl8180_bss_info_changed()
1560 cancel_delayed_work_sync(&vif_priv->beacon_work); in rtl8180_bss_info_changed()
1561 if (vif_priv->enable_beacon) in rtl8180_bss_info_changed()
1562 schedule_work(&vif_priv->beacon_work.work); in rtl8180_bss_info_changed()
1577 struct rtl8180_priv *priv = dev->priv; in rtl8180_configure_filter()
1580 priv->rx_conf ^= RTL818X_RX_CONF_FCS; in rtl8180_configure_filter()
1582 priv->rx_conf ^= RTL818X_RX_CONF_CTRL; in rtl8180_configure_filter()
1584 priv->rx_conf ^= RTL818X_RX_CONF_MONITOR; in rtl8180_configure_filter()
1586 priv->rx_conf |= RTL818X_RX_CONF_MULTICAST; in rtl8180_configure_filter()
1588 priv->rx_conf &= ~RTL818X_RX_CONF_MULTICAST; in rtl8180_configure_filter()
1592 if (priv->rx_conf & RTL818X_RX_CONF_FCS) in rtl8180_configure_filter()
1594 if (priv->rx_conf & RTL818X_RX_CONF_CTRL) in rtl8180_configure_filter()
1596 if (priv->rx_conf & RTL818X_RX_CONF_MONITOR) in rtl8180_configure_filter()
1598 if (priv->rx_conf & RTL818X_RX_CONF_MULTICAST) in rtl8180_configure_filter()
1601 rtl818x_iowrite32(priv, &priv->map->RX_CONF, priv->rx_conf); in rtl8180_configure_filter()
1620 struct rtl8180_priv *priv = eeprom->data; in rtl8180_eeprom_register_read()
1621 u8 reg = rtl818x_ioread8(priv, &priv->map->EEPROM_CMD); in rtl8180_eeprom_register_read()
1623 eeprom->reg_data_in = reg & RTL818X_EEPROM_CMD_WRITE; in rtl8180_eeprom_register_read()
1624 eeprom->reg_data_out = reg & RTL818X_EEPROM_CMD_READ; in rtl8180_eeprom_register_read()
1625 eeprom->reg_data_clock = reg & RTL818X_EEPROM_CMD_CK; in rtl8180_eeprom_register_read()
1626 eeprom->reg_chip_select = reg & RTL818X_EEPROM_CMD_CS; in rtl8180_eeprom_register_read()
1631 struct rtl8180_priv *priv = eeprom->data; in rtl8180_eeprom_register_write()
1634 if (eeprom->reg_data_in) in rtl8180_eeprom_register_write()
1636 if (eeprom->reg_data_out) in rtl8180_eeprom_register_write()
1638 if (eeprom->reg_data_clock) in rtl8180_eeprom_register_write()
1640 if (eeprom->reg_chip_select) in rtl8180_eeprom_register_write()
1643 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, reg); in rtl8180_eeprom_register_write()
1644 rtl818x_ioread8(priv, &priv->map->EEPROM_CMD); in rtl8180_eeprom_register_write()
1658 if (rtl818x_ioread32(priv, &priv->map->RX_CONF) & (1 << 6)) in rtl8180_eeprom_read()
1663 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, in rtl8180_eeprom_read()
1665 rtl818x_ioread8(priv, &priv->map->EEPROM_CMD); in rtl8180_eeprom_read()
1670 priv->rf_type = eeprom_val; in rtl8180_eeprom_read()
1673 priv->csthreshold = eeprom_val >> 8; in rtl8180_eeprom_read()
1675 eeprom_93cx6_multiread(&eeprom, 0x7, (__le16 *)priv->mac_addr, 3); in rtl8180_eeprom_read()
1677 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_eeprom_read()
1687 priv->channels[i].hw_value = txpwr & 0xFF; in rtl8180_eeprom_read()
1688 priv->channels[i + 1].hw_value = txpwr >> 8; in rtl8180_eeprom_read()
1692 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_eeprom_read()
1696 priv->channels[i].hw_value |= (txpwr & 0xFF) << 8; in rtl8180_eeprom_read()
1697 priv->channels[i + 1].hw_value |= txpwr & 0xFF00; in rtl8180_eeprom_read()
1701 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_eeprom_read()
1704 priv->anaparam = le32_to_cpu(anaparam); in rtl8180_eeprom_read()
1705 eeprom_93cx6_read(&eeprom, 0x19, &priv->rfparam); in rtl8180_eeprom_read()
1708 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_eeprom_read()
1710 priv->antenna_diversity_en = !!(eeprom_val & 0x100); in rtl8180_eeprom_read()
1711 priv->antenna_diversity_default = (eeprom_val & 0xC00) == 0x400; in rtl8180_eeprom_read()
1714 priv->xtal_out = eeprom_val & 0xF; in rtl8180_eeprom_read()
1715 priv->xtal_in = (eeprom_val & 0xF0) >> 4; in rtl8180_eeprom_read()
1716 priv->xtal_cal = !!(eeprom_val & 0x1000); in rtl8180_eeprom_read()
1717 priv->thermal_meter_val = (eeprom_val & 0xF00) >> 8; in rtl8180_eeprom_read()
1718 priv->thermal_meter_en = !!(eeprom_val & 0x2000); in rtl8180_eeprom_read()
1721 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, in rtl8180_eeprom_read()
1757 err = -ENOMEM; in rtl8180_probe()
1761 if ((err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) || in rtl8180_probe()
1762 (err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)))) { in rtl8180_probe()
1774 err = -ENOMEM; in rtl8180_probe()
1778 priv = dev->priv; in rtl8180_probe()
1779 priv->pdev = pdev; in rtl8180_probe()
1781 dev->max_rates = 1; in rtl8180_probe()
1782 SET_IEEE80211_DEV(dev, &pdev->dev); in rtl8180_probe()
1785 priv->map_pio = false; in rtl8180_probe()
1786 priv->map = pci_iomap(pdev, 1, mem_len); in rtl8180_probe()
1787 if (!priv->map) { in rtl8180_probe()
1788 priv->map = pci_iomap(pdev, 0, io_len); in rtl8180_probe()
1789 priv->map_pio = true; in rtl8180_probe()
1792 if (!priv->map) { in rtl8180_probe()
1793 dev_err(&pdev->dev, "Cannot map device memory/PIO\n"); in rtl8180_probe()
1794 err = -ENOMEM; in rtl8180_probe()
1798 BUILD_BUG_ON(sizeof(priv->channels) != sizeof(rtl818x_channels)); in rtl8180_probe()
1799 BUILD_BUG_ON(sizeof(priv->rates) != sizeof(rtl818x_rates)); in rtl8180_probe()
1801 memcpy(priv->channels, rtl818x_channels, sizeof(rtl818x_channels)); in rtl8180_probe()
1802 memcpy(priv->rates, rtl818x_rates, sizeof(rtl818x_rates)); in rtl8180_probe()
1804 priv->band.band = NL80211_BAND_2GHZ; in rtl8180_probe()
1805 priv->band.channels = priv->channels; in rtl8180_probe()
1806 priv->band.n_channels = ARRAY_SIZE(rtl818x_channels); in rtl8180_probe()
1807 priv->band.bitrates = priv->rates; in rtl8180_probe()
1808 priv->band.n_bitrates = 4; in rtl8180_probe()
1809 dev->wiphy->bands[NL80211_BAND_2GHZ] = &priv->band; in rtl8180_probe()
1814 dev->vif_data_size = sizeof(struct rtl8180_vif); in rtl8180_probe()
1815 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | in rtl8180_probe()
1817 dev->max_signal = 65; in rtl8180_probe()
1819 reg = rtl818x_ioread32(priv, &priv->map->TX_CONF); in rtl8180_probe()
1824 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8180; in rtl8180_probe()
1829 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8180; in rtl8180_probe()
1834 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8185; in rtl8180_probe()
1839 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8185; in rtl8180_probe()
1844 if (priv->map_pio) { in rtl8180_probe()
1845 dev_err(&pdev->dev, in rtl8180_probe()
1847 err = -ENOMEM; in rtl8180_probe()
1850 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8187SE; in rtl8180_probe()
1856 err = -ENODEV; in rtl8180_probe()
1867 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_probe()
1868 dev->queues = RTL8187SE_NR_TX_QUEUES - 1; in rtl8180_probe()
1870 dev->queues = RTL8180_NR_TX_QUEUES - 1; in rtl8180_probe()
1872 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_probe()
1873 priv->band.n_bitrates = ARRAY_SIZE(rtl818x_rates); in rtl8180_probe()
1877 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_probe()
1882 wiphy_ext_feature_set(dev->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); in rtl8180_probe()
1886 switch (priv->rf_type) { in rtl8180_probe()
1891 case 3: priv->rf = &sa2400_rf_ops; in rtl8180_probe()
1893 case 4: priv->rf = &max2820_rf_ops; in rtl8180_probe()
1895 case 5: priv->rf = &grf5101_rf_ops; in rtl8180_probe()
1898 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_probe()
1899 priv->rf = rtl8187se_detect_rf(dev); in rtl8180_probe()
1901 priv->rf = rtl8180_detect_rf(dev); in rtl8180_probe()
1908 pci_name(pdev), priv->rf_type); in rtl8180_probe()
1909 err = -ENODEV; in rtl8180_probe()
1913 if (!priv->rf) { in rtl8180_probe()
1916 err = -ENODEV; in rtl8180_probe()
1920 if (!is_valid_ether_addr(priv->mac_addr)) { in rtl8180_probe()
1923 eth_random_addr(priv->mac_addr); in rtl8180_probe()
1925 SET_IEEE80211_PERM_ADDR(dev, priv->mac_addr); in rtl8180_probe()
1927 spin_lock_init(&priv->lock); in rtl8180_probe()
1936 wiphy_info(dev->wiphy, "hwaddr %pm, %s + %s\n", in rtl8180_probe()
1937 priv->mac_addr, chip_name, priv->rf->name); in rtl8180_probe()
1942 pci_iounmap(pdev, priv->map); in rtl8180_probe()
1965 priv = dev->priv; in rtl8180_remove()
1967 pci_iounmap(pdev, priv->map); in rtl8180_remove()