diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2012-01-02 13:31:21 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-01-24 14:06:05 -0500 |
commit | 5056635c10151970d87ae256b7f52f056291799e (patch) | |
tree | ce2c794604507112e2da0202d755f9f85a097451 /drivers/net | |
parent | 507f9a71846a3d25d0e5322754da6b65adceda80 (diff) |
b43: add maskset helpers
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/b43/b43.h | 12 | ||||
-rw-r--r-- | drivers/net/wireless/b43/main.c | 67 | ||||
-rw-r--r-- | drivers/net/wireless/b43/phy_n.c | 14 |
3 files changed, 36 insertions, 57 deletions
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h index 16e8f8058155..835462dc1206 100644 --- a/drivers/net/wireless/b43/b43.h +++ b/drivers/net/wireless/b43/b43.h | |||
@@ -999,6 +999,12 @@ static inline void b43_write16(struct b43_wldev *dev, u16 offset, u16 value) | |||
999 | dev->dev->write16(dev->dev, offset, value); | 999 | dev->dev->write16(dev->dev, offset, value); |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | static inline void b43_maskset16(struct b43_wldev *dev, u16 offset, u16 mask, | ||
1003 | u16 set) | ||
1004 | { | ||
1005 | b43_write16(dev, offset, (b43_read16(dev, offset) & mask) | set); | ||
1006 | } | ||
1007 | |||
1002 | static inline u32 b43_read32(struct b43_wldev *dev, u16 offset) | 1008 | static inline u32 b43_read32(struct b43_wldev *dev, u16 offset) |
1003 | { | 1009 | { |
1004 | return dev->dev->read32(dev->dev, offset); | 1010 | return dev->dev->read32(dev->dev, offset); |
@@ -1009,6 +1015,12 @@ static inline void b43_write32(struct b43_wldev *dev, u16 offset, u32 value) | |||
1009 | dev->dev->write32(dev->dev, offset, value); | 1015 | dev->dev->write32(dev->dev, offset, value); |
1010 | } | 1016 | } |
1011 | 1017 | ||
1018 | static inline void b43_maskset32(struct b43_wldev *dev, u16 offset, u32 mask, | ||
1019 | u32 set) | ||
1020 | { | ||
1021 | b43_write32(dev, offset, (b43_read32(dev, offset) & mask) | set); | ||
1022 | } | ||
1023 | |||
1012 | static inline void b43_block_read(struct b43_wldev *dev, void *buffer, | 1024 | static inline void b43_block_read(struct b43_wldev *dev, void *buffer, |
1013 | size_t count, u16 offset, u8 reg_width) | 1025 | size_t count, u16 offset, u8 reg_width) |
1014 | { | 1026 | { |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index b91f28ef1032..268f2db5237b 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -578,22 +578,14 @@ void b43_tsf_read(struct b43_wldev *dev, u64 *tsf) | |||
578 | 578 | ||
579 | static void b43_time_lock(struct b43_wldev *dev) | 579 | static void b43_time_lock(struct b43_wldev *dev) |
580 | { | 580 | { |
581 | u32 macctl; | 581 | b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_TBTTHOLD); |
582 | |||
583 | macctl = b43_read32(dev, B43_MMIO_MACCTL); | ||
584 | macctl |= B43_MACCTL_TBTTHOLD; | ||
585 | b43_write32(dev, B43_MMIO_MACCTL, macctl); | ||
586 | /* Commit the write */ | 582 | /* Commit the write */ |
587 | b43_read32(dev, B43_MMIO_MACCTL); | 583 | b43_read32(dev, B43_MMIO_MACCTL); |
588 | } | 584 | } |
589 | 585 | ||
590 | static void b43_time_unlock(struct b43_wldev *dev) | 586 | static void b43_time_unlock(struct b43_wldev *dev) |
591 | { | 587 | { |
592 | u32 macctl; | 588 | b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_TBTTHOLD, 0); |
593 | |||
594 | macctl = b43_read32(dev, B43_MMIO_MACCTL); | ||
595 | macctl &= ~B43_MACCTL_TBTTHOLD; | ||
596 | b43_write32(dev, B43_MMIO_MACCTL, macctl); | ||
597 | /* Commit the write */ | 589 | /* Commit the write */ |
598 | b43_read32(dev, B43_MMIO_MACCTL); | 590 | b43_read32(dev, B43_MMIO_MACCTL); |
599 | } | 591 | } |
@@ -2485,10 +2477,8 @@ static int b43_upload_microcode(struct b43_wldev *dev) | |||
2485 | b43_write32(dev, B43_MMIO_GEN_IRQ_REASON, B43_IRQ_ALL); | 2477 | b43_write32(dev, B43_MMIO_GEN_IRQ_REASON, B43_IRQ_ALL); |
2486 | 2478 | ||
2487 | /* Start the microcode PSM */ | 2479 | /* Start the microcode PSM */ |
2488 | macctl = b43_read32(dev, B43_MMIO_MACCTL); | 2480 | b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_PSM_JMP0, |
2489 | macctl &= ~B43_MACCTL_PSM_JMP0; | 2481 | B43_MACCTL_PSM_RUN); |
2490 | macctl |= B43_MACCTL_PSM_RUN; | ||
2491 | b43_write32(dev, B43_MMIO_MACCTL, macctl); | ||
2492 | 2482 | ||
2493 | /* Wait for the microcode to load and respond */ | 2483 | /* Wait for the microcode to load and respond */ |
2494 | i = 0; | 2484 | i = 0; |
@@ -2588,10 +2578,9 @@ static int b43_upload_microcode(struct b43_wldev *dev) | |||
2588 | return 0; | 2578 | return 0; |
2589 | 2579 | ||
2590 | error: | 2580 | error: |
2591 | macctl = b43_read32(dev, B43_MMIO_MACCTL); | 2581 | /* Stop the microcode PSM. */ |
2592 | macctl &= ~B43_MACCTL_PSM_RUN; | 2582 | b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_PSM_RUN, |
2593 | macctl |= B43_MACCTL_PSM_JMP0; | 2583 | B43_MACCTL_PSM_JMP0); |
2594 | b43_write32(dev, B43_MMIO_MACCTL, macctl); | ||
2595 | 2584 | ||
2596 | return err; | 2585 | return err; |
2597 | } | 2586 | } |
@@ -2706,11 +2695,8 @@ static int b43_gpio_init(struct b43_wldev *dev) | |||
2706 | struct ssb_device *gpiodev; | 2695 | struct ssb_device *gpiodev; |
2707 | u32 mask, set; | 2696 | u32 mask, set; |
2708 | 2697 | ||
2709 | b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL) | 2698 | b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_GPOUTSMSK, 0); |
2710 | & ~B43_MACCTL_GPOUTSMSK); | 2699 | b43_maskset16(dev, B43_MMIO_GPIO_MASK, ~0, 0xF); |
2711 | |||
2712 | b43_write16(dev, B43_MMIO_GPIO_MASK, b43_read16(dev, B43_MMIO_GPIO_MASK) | ||
2713 | | 0x000F); | ||
2714 | 2700 | ||
2715 | mask = 0x0000001F; | 2701 | mask = 0x0000001F; |
2716 | set = 0x0000000F; | 2702 | set = 0x0000000F; |
@@ -2798,9 +2784,7 @@ void b43_mac_enable(struct b43_wldev *dev) | |||
2798 | dev->mac_suspended--; | 2784 | dev->mac_suspended--; |
2799 | B43_WARN_ON(dev->mac_suspended < 0); | 2785 | B43_WARN_ON(dev->mac_suspended < 0); |
2800 | if (dev->mac_suspended == 0) { | 2786 | if (dev->mac_suspended == 0) { |
2801 | b43_write32(dev, B43_MMIO_MACCTL, | 2787 | b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_ENABLED); |
2802 | b43_read32(dev, B43_MMIO_MACCTL) | ||
2803 | | B43_MACCTL_ENABLED); | ||
2804 | b43_write32(dev, B43_MMIO_GEN_IRQ_REASON, | 2788 | b43_write32(dev, B43_MMIO_GEN_IRQ_REASON, |
2805 | B43_IRQ_MAC_SUSPENDED); | 2789 | B43_IRQ_MAC_SUSPENDED); |
2806 | /* Commit writes */ | 2790 | /* Commit writes */ |
@@ -2821,9 +2805,7 @@ void b43_mac_suspend(struct b43_wldev *dev) | |||
2821 | 2805 | ||
2822 | if (dev->mac_suspended == 0) { | 2806 | if (dev->mac_suspended == 0) { |
2823 | b43_power_saving_ctl_bits(dev, B43_PS_AWAKE); | 2807 | b43_power_saving_ctl_bits(dev, B43_PS_AWAKE); |
2824 | b43_write32(dev, B43_MMIO_MACCTL, | 2808 | b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_ENABLED, 0); |
2825 | b43_read32(dev, B43_MMIO_MACCTL) | ||
2826 | & ~B43_MACCTL_ENABLED); | ||
2827 | /* force pci to flush the write */ | 2809 | /* force pci to flush the write */ |
2828 | b43_read32(dev, B43_MMIO_MACCTL); | 2810 | b43_read32(dev, B43_MMIO_MACCTL); |
2829 | for (i = 35; i; i--) { | 2811 | for (i = 35; i; i--) { |
@@ -2929,15 +2911,10 @@ static void b43_adjust_opmode(struct b43_wldev *dev) | |||
2929 | * so always disable it. If we want to implement PMQ, | 2911 | * so always disable it. If we want to implement PMQ, |
2930 | * we need to enable it here (clear DISCPMQ) in AP mode. | 2912 | * we need to enable it here (clear DISCPMQ) in AP mode. |
2931 | */ | 2913 | */ |
2932 | if (0 /* ctl & B43_MACCTL_AP */) { | 2914 | if (0 /* ctl & B43_MACCTL_AP */) |
2933 | b43_write32(dev, B43_MMIO_MACCTL, | 2915 | b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_DISCPMQ, 0); |
2934 | b43_read32(dev, B43_MMIO_MACCTL) | 2916 | else |
2935 | & ~B43_MACCTL_DISCPMQ); | 2917 | b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_DISCPMQ); |
2936 | } else { | ||
2937 | b43_write32(dev, B43_MMIO_MACCTL, | ||
2938 | b43_read32(dev, B43_MMIO_MACCTL) | ||
2939 | | B43_MACCTL_DISCPMQ); | ||
2940 | } | ||
2941 | } | 2918 | } |
2942 | 2919 | ||
2943 | static void b43_rate_memory_write(struct b43_wldev *dev, u16 rate, int is_ofdm) | 2920 | static void b43_rate_memory_write(struct b43_wldev *dev, u16 rate, int is_ofdm) |
@@ -3081,10 +3058,8 @@ static int b43_chip_init(struct b43_wldev *dev) | |||
3081 | if (dev->dev->core_rev < 5) | 3058 | if (dev->dev->core_rev < 5) |
3082 | b43_write32(dev, 0x010C, 0x01000000); | 3059 | b43_write32(dev, 0x010C, 0x01000000); |
3083 | 3060 | ||
3084 | b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL) | 3061 | b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_INFRA, 0); |
3085 | & ~B43_MACCTL_INFRA); | 3062 | b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_INFRA); |
3086 | b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL) | ||
3087 | | B43_MACCTL_INFRA); | ||
3088 | 3063 | ||
3089 | /* Probe Response Timeout value */ | 3064 | /* Probe Response Timeout value */ |
3090 | /* FIXME: Default to 0, has to be set by ioctl probably... :-/ */ | 3065 | /* FIXME: Default to 0, has to be set by ioctl probably... :-/ */ |
@@ -4562,8 +4537,6 @@ static void b43_set_pretbtt(struct b43_wldev *dev) | |||
4562 | /* Locking: wl->mutex */ | 4537 | /* Locking: wl->mutex */ |
4563 | static void b43_wireless_core_exit(struct b43_wldev *dev) | 4538 | static void b43_wireless_core_exit(struct b43_wldev *dev) |
4564 | { | 4539 | { |
4565 | u32 macctl; | ||
4566 | |||
4567 | B43_WARN_ON(dev && b43_status(dev) > B43_STAT_INITIALIZED); | 4540 | B43_WARN_ON(dev && b43_status(dev) > B43_STAT_INITIALIZED); |
4568 | if (!dev || b43_status(dev) != B43_STAT_INITIALIZED) | 4541 | if (!dev || b43_status(dev) != B43_STAT_INITIALIZED) |
4569 | return; | 4542 | return; |
@@ -4574,10 +4547,8 @@ static void b43_wireless_core_exit(struct b43_wldev *dev) | |||
4574 | b43_set_status(dev, B43_STAT_UNINIT); | 4547 | b43_set_status(dev, B43_STAT_UNINIT); |
4575 | 4548 | ||
4576 | /* Stop the microcode PSM. */ | 4549 | /* Stop the microcode PSM. */ |
4577 | macctl = b43_read32(dev, B43_MMIO_MACCTL); | 4550 | b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_PSM_RUN, |
4578 | macctl &= ~B43_MACCTL_PSM_RUN; | 4551 | B43_MACCTL_PSM_JMP0); |
4579 | macctl |= B43_MACCTL_PSM_JMP0; | ||
4580 | b43_write32(dev, B43_MMIO_MACCTL, macctl); | ||
4581 | 4552 | ||
4582 | b43_dma_free(dev); | 4553 | b43_dma_free(dev); |
4583 | b43_pio_free(dev); | 4554 | b43_pio_free(dev); |
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index bf5a43855358..9530f12c0282 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c | |||
@@ -3968,13 +3968,10 @@ static void b43_nphy_superswitch_init(struct b43_wldev *dev, bool init) | |||
3968 | #endif | 3968 | #endif |
3969 | } | 3969 | } |
3970 | 3970 | ||
3971 | b43_write32(dev, B43_MMIO_MACCTL, | 3971 | b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_GPOUTSMSK, 0); |
3972 | b43_read32(dev, B43_MMIO_MACCTL) & | 3972 | b43_maskset16(dev, B43_MMIO_GPIO_MASK, ~0, 0xFC00); |
3973 | ~B43_MACCTL_GPOUTSMSK); | 3973 | b43_maskset16(dev, B43_MMIO_GPIO_CONTROL, (~0xFC00 & 0xFFFF), |
3974 | b43_write16(dev, B43_MMIO_GPIO_MASK, | 3974 | 0); |
3975 | b43_read16(dev, B43_MMIO_GPIO_MASK) | 0xFC00); | ||
3976 | b43_write16(dev, B43_MMIO_GPIO_CONTROL, | ||
3977 | b43_read16(dev, B43_MMIO_GPIO_CONTROL) & ~0xFC00); | ||
3978 | 3975 | ||
3979 | if (init) { | 3976 | if (init) { |
3980 | b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_LO1, 0x2D8); | 3977 | b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_LO1, 0x2D8); |
@@ -4530,8 +4527,7 @@ static void b43_nphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask, | |||
4530 | { | 4527 | { |
4531 | check_phyreg(dev, reg); | 4528 | check_phyreg(dev, reg); |
4532 | b43_write16(dev, B43_MMIO_PHY_CONTROL, reg); | 4529 | b43_write16(dev, B43_MMIO_PHY_CONTROL, reg); |
4533 | b43_write16(dev, B43_MMIO_PHY_DATA, | 4530 | b43_maskset16(dev, B43_MMIO_PHY_DATA, mask, set); |
4534 | (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set); | ||
4535 | } | 4531 | } |
4536 | 4532 | ||
4537 | static u16 b43_nphy_op_radio_read(struct b43_wldev *dev, u16 reg) | 4533 | static u16 b43_nphy_op_radio_read(struct b43_wldev *dev, u16 reg) |