Lines Matching refs:priv

197 	struct rtl8180_priv *priv = dev->priv;  in rtl8180_write_phy()  local
203 rtl818x_iowrite32(priv, (__le32 __iomem *)&priv->map->PHY[0], buf | 0x80); 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() local
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()
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()
283 switch (priv->chip_family) { in rtl8180_handle_rx()
292 signal = priv->rf->calc_rssi(agc, sq); in rtl8180_handle_rx()
326 priv->rx_buf[priv->rx_idx] = skb; in rtl8180_handle_rx()
335 if (priv->rx_idx == 31) 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() local
345 struct rtl8180_tx_ring *ring = &priv->tx_ring[prio]; in rtl8180_handle_tx()
358 dma_unmap_single(&priv->pdev->dev, le32_to_cpu(entry->tx_buf), in rtl8180_handle_tx()
379 struct rtl8180_priv *priv = dev->priv; in rtl8187se_interrupt() local
384 spin_lock_irqsave(&priv->lock, flags); 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()
421 spin_unlock_irqrestore(&priv->lock, flags); in rtl8187se_interrupt()
428 struct rtl8180_priv *priv = dev->priv; in rtl8180_interrupt() local
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()
460 struct rtl8180_priv *priv = dev->priv; in rtl8180_tx() local
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()
494 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_tx()
507 rts_duration = ieee80211_rts_duration(dev, priv->vif, in rtl8180_tx()
512 rts_duration = ieee80211_ctstoself_duration(dev, priv->vif, in rtl8180_tx()
516 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) { 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()
536 frame_duration = priv->ack_time + le16_to_cpu(duration); in rtl8180_tx()
539 spin_lock_irqsave(&priv->lock, flags); in rtl8180_tx()
543 priv->seqno += 0x10; in rtl8180_tx()
545 hdr->seq_ctrl |= cpu_to_le16(priv->seqno); in rtl8180_tx()
551 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { 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()
596 static void rtl8180_set_anaparam3(struct rtl8180_priv *priv, u16 anaparam3) in rtl8180_set_anaparam3() argument
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()
616 void rtl8180_set_anaparam2(struct rtl8180_priv *priv, u32 anaparam2) in rtl8180_set_anaparam2() argument
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()
636 void rtl8180_set_anaparam(struct rtl8180_priv *priv, u32 anaparam) in rtl8180_set_anaparam() argument
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() local
655 rtl818x_iowrite32(priv, REG_ADDR4(0x1F0), 0); in rtl8187se_mac_config()
656 rtl818x_ioread32(priv, REG_ADDR4(0x1F0)); in rtl8187se_mac_config()
657 rtl818x_iowrite32(priv, REG_ADDR4(0x1F4), 0); in rtl8187se_mac_config()
658 rtl818x_ioread32(priv, REG_ADDR4(0x1F4)); in rtl8187se_mac_config()
659 rtl818x_iowrite8(priv, REG_ADDR1(0x1F8), 0); in rtl8187se_mac_config()
660 rtl818x_ioread8(priv, REG_ADDR1(0x1F8)); 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()
665 rtl818x_iowrite16(priv, PI_DATA_REG, 0x1000); in rtl8187se_mac_config()
666 rtl818x_iowrite16(priv, SI_DATA_REG, 0x1000); in rtl8187se_mac_config()
668 rtl818x_iowrite16(priv, REG_ADDR2(0x370), 0x0560); in rtl8187se_mac_config()
669 rtl818x_iowrite16(priv, REG_ADDR2(0x372), 0x0560); in rtl8187se_mac_config()
670 rtl818x_iowrite16(priv, REG_ADDR2(0x374), 0x0DA4); in rtl8187se_mac_config()
671 rtl818x_iowrite16(priv, REG_ADDR2(0x376), 0x0DA4); in rtl8187se_mac_config()
672 rtl818x_iowrite16(priv, REG_ADDR2(0x378), 0x0560); in rtl8187se_mac_config()
673 rtl818x_iowrite16(priv, REG_ADDR2(0x37A), 0x0560); in rtl8187se_mac_config()
674 rtl818x_iowrite16(priv, REG_ADDR2(0x37C), 0x00EC); in rtl8187se_mac_config()
675 rtl818x_iowrite16(priv, REG_ADDR2(0x37E), 0x00EC); in rtl8187se_mac_config()
676 rtl818x_iowrite8(priv, REG_ADDR1(0x24E), 0x01); in rtl8187se_mac_config()
678 rtl818x_iowrite8(priv, REG_ADDR1(0x0A), 0x72); in rtl8187se_mac_config()
684 struct rtl8180_priv *priv = dev->priv; in rtl8187se_set_antenna_config() local
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()
721 struct rtl8180_priv *priv = dev->priv; in rtl8180_int_enable() local
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() local
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() local
767 switch (priv->chip_family) { 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()
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() local
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()
807 rtl818x_iowrite16(priv, FEMR_SE, 0xffff); 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() local
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()
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()
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()
922 rtl818x_iowrite8(priv, REG_ADDR1(0xff), 0x35); in rtl8180_init_hw()
923 rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg); in rtl8180_init_hw()
925 rtl818x_iowrite8(priv, REG_ADDR1(0x1ff), 0x35); in rtl8180_init_hw()
928 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_init_hw()
931 rtl818x_iowrite16(priv, ARFR, 0xFFF); in rtl8180_init_hw()
932 rtl818x_ioread16(priv, ARFR); 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()
946 rtl818x_iowrite16(priv, RFSW_CTRL, 0x569A); in rtl8180_init_hw()
947 rtl818x_ioread16(priv, RFSW_CTRL); in rtl8180_init_hw()
949 rtl8180_set_anaparam(priv, RTL8225SE_ANAPARAM_ON); in rtl8180_init_hw()
950 rtl8180_set_anaparam2(priv, RTL8225SE_ANAPARAM2_ON); in rtl8180_init_hw()
951 rtl8180_set_anaparam3(priv, RTL8225SE_ANAPARAM3); 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()
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() local
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()
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()
1032 priv->rx_buf[i] = skb; 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()
1057 struct rtl8180_priv *priv = dev->priv; in rtl8180_free_rx_ring() local
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() local
1083 ring = dma_alloc_coherent(&priv->pdev->dev, sizeof(*ring) * entries, 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() local
1107 struct rtl8180_tx_ring *ring = &priv->tx_ring[prio]; in rtl8180_free_tx_ring()
1113 dma_unmap_single(&priv->pdev->dev, le32_to_cpu(entry->tx_buf), in rtl8180_free_tx_ring()
1119 dma_free_coherent(&priv->pdev->dev, in rtl8180_free_tx_ring()
1127 struct rtl8180_priv *priv = dev->priv; in rtl8180_start() local
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()
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()
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()
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()
1246 if (priv->tx_ring[i].desc) in rtl8180_start()
1254 struct rtl8180_priv *priv = dev->priv; in rtl8180_stop() local
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()
1282 struct rtl8180_priv *priv = dev->priv; in rtl8180_get_tsf() local
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()
1331 struct rtl8180_priv *priv = dev->priv; in rtl8180_add_interface() local
1337 if (priv->vif) in rtl8180_add_interface()
1348 priv->vif = vif; 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()
1359 rtl818x_iowrite16(priv, (__le16 __iomem *)&priv->map->MAC[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() local
1370 priv->vif = NULL; in rtl8180_remove_interface()
1375 struct rtl8180_priv *priv = dev->priv; in rtl8180_config() local
1378 priv->rf->set_chan(dev, conf); in rtl8180_config()
1386 struct rtl8180_priv *priv = dev->priv; in rtl8187se_conf_ac_parm() local
1395 params = &priv->queue_param[queue]; in rtl8187se_conf_ac_parm()
1400 aifs = 10 + params->aifs * priv->slot_time; 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() local
1435 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) 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() local
1459 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) 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()
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() local
1514 rtl818x_iowrite16(priv, (__le16 __iomem *)&priv->map->BSSID[0], in rtl8180_bss_info_changed()
1516 rtl818x_iowrite32(priv, (__le32 __iomem *)&priv->map->BSSID[2], 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()
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()
1582 struct rtl8180_priv *priv = dev->priv; in rtl8180_configure_filter() local
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()
1626 struct rtl8180_priv *priv = eeprom->data; in rtl8180_eeprom_register_read() local
1627 u8 reg = rtl818x_ioread8(priv, &priv->map->EEPROM_CMD); in rtl8180_eeprom_register_read()
1637 struct rtl8180_priv *priv = eeprom->data; in rtl8180_eeprom_register_write() local
1649 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, reg); in rtl8180_eeprom_register_write()
1650 rtl818x_ioread8(priv, &priv->map->EEPROM_CMD); in rtl8180_eeprom_register_write()
1654 static void rtl8180_eeprom_read(struct rtl8180_priv *priv) in rtl8180_eeprom_read() argument
1661 eeprom.data = priv; in rtl8180_eeprom_read()
1664 if (rtl818x_ioread32(priv, &priv->map->RX_CONF) & (1 << 6)) in rtl8180_eeprom_read()
1669 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, in rtl8180_eeprom_read()
1671 rtl818x_ioread8(priv, &priv->map->EEPROM_CMD); in rtl8180_eeprom_read()
1676 priv->rf_type = eeprom_val; in rtl8180_eeprom_read()
1679 priv->csthreshold = eeprom_val >> 8; in rtl8180_eeprom_read()
1681 eeprom_93cx6_multiread(&eeprom, 0x7, (__le16 *)priv->mac_addr, 3); in rtl8180_eeprom_read()
1683 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_eeprom_read()
1693 priv->channels[i].hw_value = txpwr & 0xFF; in rtl8180_eeprom_read()
1694 priv->channels[i + 1].hw_value = txpwr >> 8; in rtl8180_eeprom_read()
1698 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_eeprom_read()
1702 priv->channels[i].hw_value |= (txpwr & 0xFF) << 8; in rtl8180_eeprom_read()
1703 priv->channels[i + 1].hw_value |= txpwr & 0xFF00; in rtl8180_eeprom_read()
1707 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_eeprom_read()
1710 priv->anaparam = le32_to_cpu(anaparam); in rtl8180_eeprom_read()
1711 eeprom_93cx6_read(&eeprom, 0x19, &priv->rfparam); in rtl8180_eeprom_read()
1714 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) { in rtl8180_eeprom_read()
1716 priv->antenna_diversity_en = !!(eeprom_val & 0x100); in rtl8180_eeprom_read()
1717 priv->antenna_diversity_default = (eeprom_val & 0xC00) == 0x400; in rtl8180_eeprom_read()
1720 priv->xtal_out = eeprom_val & 0xF; in rtl8180_eeprom_read()
1721 priv->xtal_in = (eeprom_val & 0xF0) >> 4; in rtl8180_eeprom_read()
1722 priv->xtal_cal = !!(eeprom_val & 0x1000); in rtl8180_eeprom_read()
1723 priv->thermal_meter_val = (eeprom_val & 0xF00) >> 8; in rtl8180_eeprom_read()
1724 priv->thermal_meter_en = !!(eeprom_val & 0x2000); in rtl8180_eeprom_read()
1727 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, in rtl8180_eeprom_read()
1735 struct rtl8180_priv *priv; in rtl8180_probe() local
1776 dev = ieee80211_alloc_hw(sizeof(*priv), &rtl8180_ops); in rtl8180_probe()
1784 priv = dev->priv; in rtl8180_probe()
1785 priv->pdev = pdev; in rtl8180_probe()
1791 priv->map_pio = false; in rtl8180_probe()
1792 priv->map = pci_iomap(pdev, 1, mem_len); in rtl8180_probe()
1793 if (!priv->map) { in rtl8180_probe()
1794 priv->map = pci_iomap(pdev, 0, io_len); in rtl8180_probe()
1795 priv->map_pio = true; in rtl8180_probe()
1798 if (!priv->map) { in rtl8180_probe()
1804 BUILD_BUG_ON(sizeof(priv->channels) != sizeof(rtl818x_channels)); in rtl8180_probe()
1805 BUILD_BUG_ON(sizeof(priv->rates) != sizeof(rtl818x_rates)); in rtl8180_probe()
1807 memcpy(priv->channels, rtl818x_channels, sizeof(rtl818x_channels)); in rtl8180_probe()
1808 memcpy(priv->rates, rtl818x_rates, sizeof(rtl818x_rates)); in rtl8180_probe()
1810 priv->band.band = NL80211_BAND_2GHZ; in rtl8180_probe()
1811 priv->band.channels = priv->channels; in rtl8180_probe()
1812 priv->band.n_channels = ARRAY_SIZE(rtl818x_channels); in rtl8180_probe()
1813 priv->band.bitrates = priv->rates; in rtl8180_probe()
1814 priv->band.n_bitrates = 4; in rtl8180_probe()
1815 dev->wiphy->bands[NL80211_BAND_2GHZ] = &priv->band; in rtl8180_probe()
1825 reg = rtl818x_ioread32(priv, &priv->map->TX_CONF); in rtl8180_probe()
1830 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8180; in rtl8180_probe()
1835 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8180; in rtl8180_probe()
1840 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8185; in rtl8180_probe()
1845 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8185; in rtl8180_probe()
1850 if (priv->map_pio) { in rtl8180_probe()
1856 priv->chip_family = RTL818X_CHIP_FAMILY_RTL8187SE; in rtl8180_probe()
1873 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_probe()
1878 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) { in rtl8180_probe()
1879 priv->band.n_bitrates = ARRAY_SIZE(rtl818x_rates); in rtl8180_probe()
1883 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) in rtl8180_probe()
1890 rtl8180_eeprom_read(priv); in rtl8180_probe()
1892 switch (priv->rf_type) { in rtl8180_probe()
1897 case 3: priv->rf = &sa2400_rf_ops; in rtl8180_probe()
1899 case 4: priv->rf = &max2820_rf_ops; in rtl8180_probe()
1901 case 5: priv->rf = &grf5101_rf_ops; in rtl8180_probe()
1904 if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) in rtl8180_probe()
1905 priv->rf = rtl8187se_detect_rf(dev); in rtl8180_probe()
1907 priv->rf = rtl8180_detect_rf(dev); in rtl8180_probe()
1914 pci_name(pdev), priv->rf_type); in rtl8180_probe()
1919 if (!priv->rf) { in rtl8180_probe()
1926 if (!is_valid_ether_addr(priv->mac_addr)) { in rtl8180_probe()
1929 eth_random_addr(priv->mac_addr); in rtl8180_probe()
1931 SET_IEEE80211_PERM_ADDR(dev, priv->mac_addr); in rtl8180_probe()
1933 spin_lock_init(&priv->lock); in rtl8180_probe()
1943 priv->mac_addr, chip_name, priv->rf->name); in rtl8180_probe()
1948 pci_iounmap(pdev, priv->map); in rtl8180_probe()
1964 struct rtl8180_priv *priv; in rtl8180_remove() local
1971 priv = dev->priv; in rtl8180_remove()
1973 pci_iounmap(pdev, priv->map); in rtl8180_remove()