diff options
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2400pci.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2400pci.c | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c index 900140d3b304..cfb720f35b2c 100644 --- a/drivers/net/wireless/rt2x00/rt2400pci.c +++ b/drivers/net/wireless/rt2x00/rt2400pci.c | |||
@@ -781,25 +781,32 @@ static int rt2400pci_init_registers(struct rt2x00_dev *rt2x00dev) | |||
781 | return 0; | 781 | return 0; |
782 | } | 782 | } |
783 | 783 | ||
784 | static int rt2400pci_init_bbp(struct rt2x00_dev *rt2x00dev) | 784 | static int rt2400pci_wait_bbp_ready(struct rt2x00_dev *rt2x00dev) |
785 | { | 785 | { |
786 | unsigned int i; | 786 | unsigned int i; |
787 | u16 eeprom; | ||
788 | u8 reg_id; | ||
789 | u8 value; | 787 | u8 value; |
790 | 788 | ||
791 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | 789 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { |
792 | rt2400pci_bbp_read(rt2x00dev, 0, &value); | 790 | rt2400pci_bbp_read(rt2x00dev, 0, &value); |
793 | if ((value != 0xff) && (value != 0x00)) | 791 | if ((value != 0xff) && (value != 0x00)) |
794 | goto continue_csr_init; | 792 | return 0; |
795 | NOTICE(rt2x00dev, "Waiting for BBP register.\n"); | ||
796 | udelay(REGISTER_BUSY_DELAY); | 793 | udelay(REGISTER_BUSY_DELAY); |
797 | } | 794 | } |
798 | 795 | ||
799 | ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); | 796 | ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); |
800 | return -EACCES; | 797 | return -EACCES; |
798 | } | ||
799 | |||
800 | static int rt2400pci_init_bbp(struct rt2x00_dev *rt2x00dev) | ||
801 | { | ||
802 | unsigned int i; | ||
803 | u16 eeprom; | ||
804 | u8 reg_id; | ||
805 | u8 value; | ||
806 | |||
807 | if (unlikely(rt2400pci_wait_bbp_ready(rt2x00dev))) | ||
808 | return -EACCES; | ||
801 | 809 | ||
802 | continue_csr_init: | ||
803 | rt2400pci_bbp_write(rt2x00dev, 1, 0x00); | 810 | rt2400pci_bbp_write(rt2x00dev, 1, 0x00); |
804 | rt2400pci_bbp_write(rt2x00dev, 3, 0x27); | 811 | rt2400pci_bbp_write(rt2x00dev, 3, 0x27); |
805 | rt2400pci_bbp_write(rt2x00dev, 4, 0x08); | 812 | rt2400pci_bbp_write(rt2x00dev, 4, 0x08); |
@@ -838,7 +845,8 @@ static void rt2400pci_toggle_rx(struct rt2x00_dev *rt2x00dev, | |||
838 | 845 | ||
839 | rt2x00pci_register_read(rt2x00dev, RXCSR0, ®); | 846 | rt2x00pci_register_read(rt2x00dev, RXCSR0, ®); |
840 | rt2x00_set_field32(®, RXCSR0_DISABLE_RX, | 847 | rt2x00_set_field32(®, RXCSR0_DISABLE_RX, |
841 | state == STATE_RADIO_RX_OFF); | 848 | (state == STATE_RADIO_RX_OFF) || |
849 | (state == STATE_RADIO_RX_OFF_LINK)); | ||
842 | rt2x00pci_register_write(rt2x00dev, RXCSR0, reg); | 850 | rt2x00pci_register_write(rt2x00dev, RXCSR0, reg); |
843 | } | 851 | } |
844 | 852 | ||
@@ -875,17 +883,10 @@ static int rt2400pci_enable_radio(struct rt2x00_dev *rt2x00dev) | |||
875 | /* | 883 | /* |
876 | * Initialize all registers. | 884 | * Initialize all registers. |
877 | */ | 885 | */ |
878 | if (rt2400pci_init_queues(rt2x00dev) || | 886 | if (unlikely(rt2400pci_init_queues(rt2x00dev) || |
879 | rt2400pci_init_registers(rt2x00dev) || | 887 | rt2400pci_init_registers(rt2x00dev) || |
880 | rt2400pci_init_bbp(rt2x00dev)) { | 888 | rt2400pci_init_bbp(rt2x00dev))) |
881 | ERROR(rt2x00dev, "Register initialization failed.\n"); | ||
882 | return -EIO; | 889 | return -EIO; |
883 | } | ||
884 | |||
885 | /* | ||
886 | * Enable interrupts. | ||
887 | */ | ||
888 | rt2400pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_ON); | ||
889 | 890 | ||
890 | return 0; | 891 | return 0; |
891 | } | 892 | } |
@@ -907,11 +908,6 @@ static void rt2400pci_disable_radio(struct rt2x00_dev *rt2x00dev) | |||
907 | rt2x00pci_register_read(rt2x00dev, TXCSR0, ®); | 908 | rt2x00pci_register_read(rt2x00dev, TXCSR0, ®); |
908 | rt2x00_set_field32(®, TXCSR0_ABORT, 1); | 909 | rt2x00_set_field32(®, TXCSR0_ABORT, 1); |
909 | rt2x00pci_register_write(rt2x00dev, TXCSR0, reg); | 910 | rt2x00pci_register_write(rt2x00dev, TXCSR0, reg); |
910 | |||
911 | /* | ||
912 | * Disable interrupts. | ||
913 | */ | ||
914 | rt2400pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_OFF); | ||
915 | } | 911 | } |
916 | 912 | ||
917 | static int rt2400pci_set_state(struct rt2x00_dev *rt2x00dev, | 913 | static int rt2400pci_set_state(struct rt2x00_dev *rt2x00dev, |
@@ -946,10 +942,6 @@ static int rt2400pci_set_state(struct rt2x00_dev *rt2x00dev, | |||
946 | msleep(10); | 942 | msleep(10); |
947 | } | 943 | } |
948 | 944 | ||
949 | NOTICE(rt2x00dev, "Device failed to enter state %d, " | ||
950 | "current device state: bbp %d and rf %d.\n", | ||
951 | state, bbp_state, rf_state); | ||
952 | |||
953 | return -EBUSY; | 945 | return -EBUSY; |
954 | } | 946 | } |
955 | 947 | ||
@@ -967,11 +959,13 @@ static int rt2400pci_set_device_state(struct rt2x00_dev *rt2x00dev, | |||
967 | break; | 959 | break; |
968 | case STATE_RADIO_RX_ON: | 960 | case STATE_RADIO_RX_ON: |
969 | case STATE_RADIO_RX_ON_LINK: | 961 | case STATE_RADIO_RX_ON_LINK: |
970 | rt2400pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON); | ||
971 | break; | ||
972 | case STATE_RADIO_RX_OFF: | 962 | case STATE_RADIO_RX_OFF: |
973 | case STATE_RADIO_RX_OFF_LINK: | 963 | case STATE_RADIO_RX_OFF_LINK: |
974 | rt2400pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF); | 964 | rt2400pci_toggle_rx(rt2x00dev, state); |
965 | break; | ||
966 | case STATE_RADIO_IRQ_ON: | ||
967 | case STATE_RADIO_IRQ_OFF: | ||
968 | rt2400pci_toggle_irq(rt2x00dev, state); | ||
975 | break; | 969 | break; |
976 | case STATE_DEEP_SLEEP: | 970 | case STATE_DEEP_SLEEP: |
977 | case STATE_SLEEP: | 971 | case STATE_SLEEP: |
@@ -984,6 +978,10 @@ static int rt2400pci_set_device_state(struct rt2x00_dev *rt2x00dev, | |||
984 | break; | 978 | break; |
985 | } | 979 | } |
986 | 980 | ||
981 | if (unlikely(retval)) | ||
982 | ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n", | ||
983 | state, retval); | ||
984 | |||
987 | return retval; | 985 | return retval; |
988 | } | 986 | } |
989 | 987 | ||