~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
171
171
static int _rtl92c_fw_free_to_go(struct ieee80211_hw *hw)
172
172
{
173
173
        struct rtl_priv *rtlpriv = rtl_priv(hw);
174
 
        int err = -EIO;
175
174
        u32 counter = 0;
176
175
        u32 value32;
177
176
 
184
183
                RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
185
184
                         ("chksum report faill ! REG_MCUFWDL:0x%08x .\n",
186
185
                          value32));
187
 
                goto exit;
 
186
                return -EIO;
188
187
        }
189
188
 
190
189
        RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
204
203
                                 ("Polling FW ready success!!"
205
204
                                 " REG_MCUFWDL:0x%08x .\n",
206
205
                                 value32));
207
 
                        err = 0;
208
 
                        goto exit;
 
206
                        return 0;
209
207
                }
210
208
 
211
209
                mdelay(FW_8192C_POLLING_DELAY);
214
212
 
215
213
        RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
216
214
                 ("Polling FW ready fail!! REG_MCUFWDL:0x%08x .\n", value32));
217
 
 
218
 
exit:
219
 
        return err;
 
215
        return -EIO;
220
216
}
221
217
 
222
218
int rtl92c_download_fw(struct ieee80211_hw *hw)
226
222
        struct rtl92c_firmware_header *pfwheader;
227
223
        u8 *pfwdata;
228
224
        u32 fwsize;
229
 
        int err;
230
225
        enum version_8192c version = rtlhal->version;
231
 
        const struct firmware *firmware;
232
226
 
233
 
        printk(KERN_INFO "rtl8192cu: Loading firmware file %s\n",
 
227
        printk(KERN_INFO "rtl8192c: Loading firmware file %s\n",
234
228
               rtlpriv->cfg->fw_name);
235
 
        err = request_firmware(&firmware, rtlpriv->cfg->fw_name,
236
 
                               rtlpriv->io.dev);
237
 
        if (err) {
238
 
                printk(KERN_ERR "rtl8192cu: Firmware loading failed\n");
239
 
                return 1;
240
 
        }
241
 
 
242
 
        if (firmware->size > 0x4000) {
243
 
                RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
244
 
                         ("Firmware is too big!\n"));
245
 
                release_firmware(firmware);
246
 
                return 1;
247
 
        }
248
 
 
249
 
        memcpy(rtlhal->pfirmware, firmware->data, firmware->size);
250
 
        fwsize = firmware->size;
251
 
        release_firmware(firmware);
 
229
        if (!rtlhal->pfirmware)
 
230
                return 1;
252
231
 
253
232
        pfwheader = (struct rtl92c_firmware_header *)rtlhal->pfirmware;
254
233
        pfwdata = (u8 *) rtlhal->pfirmware;
 
234
        fwsize = rtlhal->fwsize;
255
235
 
256
236
        if (IS_FW_HEADER_EXIST(pfwheader)) {
257
237
                RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
267
247
        _rtl92c_write_fw(hw, version, pfwdata, fwsize);
268
248
        _rtl92c_enable_fw_download(hw, false);
269
249
 
270
 
        err = _rtl92c_fw_free_to_go(hw);
271
 
        if (err) {
 
250
        if (_rtl92c_fw_free_to_go(hw)) {
272
251
                RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
273
252
                         ("Firmware is not ready to run!\n"));
274
253
        } else {
300
279
        struct rtl_priv *rtlpriv = rtl_priv(hw);
301
280
        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
302
281
        u8 boxnum;
303
 
        u16 box_reg, box_extreg;
 
282
        u16 box_reg = 0, box_extreg = 0;
304
283
        u8 u1b_tmp;
305
284
        bool isfw_read = false;
306
 
        u8 buf_index = 0;
307
285
        bool bwrite_sucess = false;
308
286
        u8 wait_h2c_limmit = 100;
309
287
        u8 wait_writeh2c_limmit = 100;
414
392
                case 1:
415
393
                        boxcontent[0] &= ~(BIT(7));
416
394
                        memcpy((u8 *) (boxcontent) + 1,
417
 
                               p_cmdbuffer + buf_index, 1);
 
395
                               p_cmdbuffer, 1);
418
396
 
419
397
                        for (idx = 0; idx < 4; idx++) {
420
398
                                rtl_write_byte(rtlpriv, box_reg + idx,
424
402
                case 2:
425
403
                        boxcontent[0] &= ~(BIT(7));
426
404
                        memcpy((u8 *) (boxcontent) + 1,
427
 
                               p_cmdbuffer + buf_index, 2);
 
405
                               p_cmdbuffer, 2);
428
406
 
429
407
                        for (idx = 0; idx < 4; idx++) {
430
408
                                rtl_write_byte(rtlpriv, box_reg + idx,
434
412
                case 3:
435
413
                        boxcontent[0] &= ~(BIT(7));
436
414
                        memcpy((u8 *) (boxcontent) + 1,
437
 
                               p_cmdbuffer + buf_index, 3);
 
415
                               p_cmdbuffer, 3);
438
416
 
439
417
                        for (idx = 0; idx < 4; idx++) {
440
418
                                rtl_write_byte(rtlpriv, box_reg + idx,
444
422
                case 4:
445
423
                        boxcontent[0] |= (BIT(7));
446
424
                        memcpy((u8 *) (boxextcontent),
447
 
                               p_cmdbuffer + buf_index, 2);
 
425
                               p_cmdbuffer, 2);
448
426
                        memcpy((u8 *) (boxcontent) + 1,
449
 
                               p_cmdbuffer + buf_index + 2, 2);
 
427
                               p_cmdbuffer + 2, 2);
450
428
 
451
429
                        for (idx = 0; idx < 2; idx++) {
452
430
                                rtl_write_byte(rtlpriv, box_extreg + idx,
461
439
                case 5:
462
440
                        boxcontent[0] |= (BIT(7));
463
441
                        memcpy((u8 *) (boxextcontent),
464
 
                               p_cmdbuffer + buf_index, 2);
 
442
                               p_cmdbuffer, 2);
465
443
                        memcpy((u8 *) (boxcontent) + 1,
466
 
                               p_cmdbuffer + buf_index + 2, 3);
 
444
                               p_cmdbuffer + 2, 3);
467
445
 
468
446
                        for (idx = 0; idx < 2; idx++) {
469
447
                                rtl_write_byte(rtlpriv, box_extreg + idx,
561
539
}
562
540
EXPORT_SYMBOL(rtl92c_set_fw_pwrmode_cmd);
563
541
 
 
542
static bool _rtl92c_cmd_send_packet(struct ieee80211_hw *hw,
 
543
                                struct sk_buff *skb)
 
544
{
 
545
        struct rtl_priv *rtlpriv = rtl_priv(hw);
 
546
        struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
 
547
        struct rtl8192_tx_ring *ring;
 
548
        struct rtl_tx_desc *pdesc;
 
549
        u8 own;
 
550
        unsigned long flags;
 
551
        struct sk_buff *pskb = NULL;
 
552
 
 
553
        ring = &rtlpci->tx_ring[BEACON_QUEUE];
 
554
 
 
555
        pskb = __skb_dequeue(&ring->queue);
 
556
        if (pskb)
 
557
                kfree_skb(pskb);
 
558
 
 
559
        spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags);
 
560
 
 
561
        pdesc = &ring->desc[0];
 
562
        own = (u8) rtlpriv->cfg->ops->get_desc((u8 *) pdesc, true, HW_DESC_OWN);
 
563
 
 
564
        rtlpriv->cfg->ops->fill_tx_cmddesc(hw, (u8 *) pdesc, 1, 1, skb);
 
565
 
 
566
        __skb_queue_tail(&ring->queue, skb);
 
567
 
 
568
        spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags);
 
569
 
 
570
        rtlpriv->cfg->ops->tx_polling(hw, BEACON_QUEUE);
 
571
 
 
572
        return true;
 
573
}
 
574
 
564
575
#define BEACON_PG               0 /*->1*/
565
576
#define PSPOLL_PG               2
566
577
#define NULL_PG                 3
678
689
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
679
690
};
680
691
 
681
 
void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
 
692
void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished)
682
693
{
683
694
        struct rtl_priv *rtlpriv = rtl_priv(hw);
684
695
        struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
687
698
        u32 totalpacketlen;
688
699
        bool rtstatus;
689
700
        u8 u1RsvdPageLoc[3] = {0};
690
 
        bool b_dlok = false;
 
701
        bool dlok = false;
691
702
 
692
703
        u8 *beacon;
693
 
        u8 *p_pspoll;
 
704
        u8 *pspoll;
694
705
        u8 *nullfunc;
695
 
        u8 *p_probersp;
 
706
        u8 *probersp;
696
707
        /*---------------------------------------------------------
697
708
                                (1) beacon
698
709
        ---------------------------------------------------------*/
703
714
        /*-------------------------------------------------------
704
715
                                (2) ps-poll
705
716
        --------------------------------------------------------*/
706
 
        p_pspoll = &reserved_page_packet[PSPOLL_PG * 128];
707
 
        SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000));
708
 
        SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid);
709
 
        SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr);
 
717
        pspoll = &reserved_page_packet[PSPOLL_PG * 128];
 
718
        SET_80211_PS_POLL_AID(pspoll, (mac->assoc_id | 0xc000));
 
719
        SET_80211_PS_POLL_BSSID(pspoll, mac->bssid);
 
720
        SET_80211_PS_POLL_TA(pspoll, mac->mac_addr);
710
721
 
711
722
        SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1RsvdPageLoc, PSPOLL_PG);
712
723
 
723
734
        /*---------------------------------------------------------
724
735
                                (4) probe response
725
736
        ----------------------------------------------------------*/
726
 
        p_probersp = &reserved_page_packet[PROBERSP_PG * 128];
727
 
        SET_80211_HDR_ADDRESS1(p_probersp, mac->bssid);
728
 
        SET_80211_HDR_ADDRESS2(p_probersp, mac->mac_addr);
729
 
        SET_80211_HDR_ADDRESS3(p_probersp, mac->bssid);
 
737
        probersp = &reserved_page_packet[PROBERSP_PG * 128];
 
738
        SET_80211_HDR_ADDRESS1(probersp, mac->bssid);
 
739
        SET_80211_HDR_ADDRESS2(probersp, mac->mac_addr);
 
740
        SET_80211_HDR_ADDRESS3(probersp, mac->bssid);
730
741
 
731
742
        SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(u1RsvdPageLoc, PROBERSP_PG);
732
743
 
744
755
        memcpy((u8 *) skb_put(skb, totalpacketlen),
745
756
               &reserved_page_packet, totalpacketlen);
746
757
 
747
 
        rtstatus = rtlpriv->cfg->ops->cmd_send_packet(hw, skb);
 
758
        rtstatus = _rtl92c_cmd_send_packet(hw, skb);
748
759
 
749
760
        if (rtstatus)
750
 
                b_dlok = true;
 
761
                dlok = true;
751
762
 
752
 
        if (b_dlok) {
 
763
        if (dlok) {
753
764
                RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
754
765
                         ("Set RSVD page location to Fw.\n"));
755
766
                RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,