Changeset a35b458 in mainline for uspace/drv/nic/ar9271/hw.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (8 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/nic/ar9271/hw.c

    r3061bc1 ra35b458  
    5757        for (size_t i = 0; i < HW_WAIT_LOOPS; i++) {
    5858                udelay(HW_WAIT_TIME_US);
    59                
     59
    6060                uint32_t result;
    6161                wmi_reg_read(ar9271->htc_device, offset, &result);
     
    6363                        return EOK;
    6464        }
    65        
     65
    6666        return ETIMEOUT;
    6767}
     
    8484                }
    8585        };
    86        
     86
    8787        wmi_reg_buffer_write(ar9271->htc_device, buffer,
    8888            sizeof(buffer) / sizeof(wmi_reg_t));
    89        
     89
    9090        udelay(2);
    91        
     91
    9292        wmi_reg_write(ar9271->htc_device, AR9271_RC, 0);
    9393        wmi_reg_write(ar9271->htc_device, AR9271_RTC_RESET, 1);
    94        
     94
    9595        errno_t rc = hw_read_wait(ar9271,
    9696            AR9271_RTC_STATUS,
     
    101101                return rc;
    102102        }
    103        
     103
    104104        return EOK;
    105105}
     
    108108{
    109109        uint32_t reset_value = AR9271_RTC_RC_MAC_WARM;
    110        
     110
    111111        if (cold)
    112112                reset_value |= AR9271_RTC_RC_MAC_COLD;
    113        
     113
    114114        wmi_reg_t buffer[] = {
    115115                {
     
    127127                }
    128128        };
    129        
     129
    130130        wmi_reg_buffer_write(ar9271->htc_device, buffer,
    131131            sizeof(buffer) / sizeof(wmi_reg_t));
    132        
     132
    133133        udelay(100);
    134        
     134
    135135        wmi_reg_write(ar9271->htc_device, AR9271_RTC_RC, 0);
    136        
     136
    137137        errno_t rc = hw_read_wait(ar9271, AR9271_RTC_RC, AR9271_RTC_RC_MASK, 0);
    138138        if (rc != EOK) {
     
    140140                return rc;
    141141        }
    142        
     142
    143143        wmi_reg_write(ar9271->htc_device, AR9271_RC, 0);
    144144        wmi_reg_clear_bit(ar9271->htc_device, AR9271_STATION_ID1,
    145145            AR9271_STATION_ID1_POWER_SAVING);
    146        
     146
    147147        return EOK;
    148148}
     
    152152        uint32_t value;
    153153        nic_address_t ar9271_address;
    154        
     154
    155155        for (unsigned int i = 0; i < 3; i++) {
    156156                wmi_reg_read(ar9271->htc_device,
    157157                    AR9271_EEPROM_MAC_ADDR_START + i * 4, &value);
    158                
     158
    159159                uint16_t two_bytes = uint16_t_be2host(value);
    160160                ar9271_address.address[2*i] = two_bytes >> 8;
    161161                ar9271_address.address[2*i+1] = two_bytes & 0xff;
    162162        }
    163        
     163
    164164        nic_t *nic = nic_get_from_ddf_dev(ar9271->ddf_dev);
    165        
     165
    166166        errno_t rc = nic_report_address(nic, &ar9271_address);
    167167        if (rc != EOK) {
     
    169169                return rc;
    170170        }
    171        
     171
    172172        return EOK;
    173173}
     
    176176{
    177177        uint32_t address;
    178        
     178
    179179        if (gpio > 11)
    180180                address = AR9271_GPIO_OUT_MUX3;
     
    183183        else
    184184                address = AR9271_GPIO_OUT_MUX1;
    185        
     185
    186186        uint32_t gpio_shift = (gpio % 6) * 5;
    187        
     187
    188188        uint32_t temp;
    189189        wmi_reg_read(ar9271->htc_device, address, &temp);
    190        
     190
    191191        temp = ((temp & 0x1f0) << 1) | (temp & ~0x1f0);
    192192        temp &= ~(0x1f << gpio_shift);
    193193        temp |= (type << gpio_shift);
    194        
     194
    195195        wmi_reg_write(ar9271->htc_device, address, temp);
    196        
     196
    197197        gpio_shift = 2 * gpio;
    198        
     198
    199199        wmi_reg_set_clear_bit(ar9271->htc_device, AR9271_GPIO_OE_OUT,
    200200            AR9271_GPIO_OE_OUT_ALWAYS << gpio_shift,
    201201            AR9271_GPIO_OE_OUT_ALWAYS << gpio_shift);
    202        
     202
    203203        return EOK;
    204204}
     
    225225                return rc;
    226226        }
    227        
     227
    228228        rc = hw_set_reset(ar9271, false);
    229229        if (rc != EOK) {
     
    231231                return rc;
    232232        }
    233        
     233
    234234        rc = hw_addr_init(ar9271);
    235235        if (rc != EOK) {
     
    237237                return rc;
    238238        }
    239        
     239
    240240        return EOK;
    241241}
     
    249249                return rc;
    250250        }
    251        
     251
    252252        rc = hw_gpio_set_value(ar9271, AR9271_LED_PIN, 0);
    253253        if (rc != EOK) {
     
    255255                return rc;
    256256        }
    257        
     257
    258258        return EOK;
    259259}
     
    263263        wmi_reg_write(ar9271->htc_device, AR9271_PHY_ACTIVE, 1);
    264264        udelay(1000);
    265        
     265
    266266        return EOK;
    267267}
     
    271271{
    272272        uint32_t set_bit = 0x10000000;
    273        
     273
    274274        switch(op_mode) {
    275275        case IEEE80211_OPMODE_ADHOC:
     
    286286                    AR9271_CONFIG_ADHOC);
    287287        }
    288        
     288
    289289        wmi_reg_set_clear_bit(ar9271->htc_device, AR9271_STATION_ID1,
    290290            set_bit, AR9271_OPMODE_STATION_AP_MASK | AR9271_OPMODE_ADHOC_MASK);
    291        
     291
    292292        ieee80211_report_current_op_mode(ar9271->ieee80211_dev, op_mode);
    293        
     293
    294294        return EOK;
    295295}
     
    302302                return rc;
    303303        }
    304        
     304
    305305        return EOK;
    306306}
     
    310310        uint32_t value;
    311311        wmi_reg_read(ar9271->htc_device, AR9271_PHY_CAL, &value);
    312        
     312
    313313        value &= 0xfffffe00;
    314314        value |= (((uint32_t) AR9271_CALIB_NOMINAL_VALUE_2GHZ << 1) & 0x1ff);
    315        
     315
    316316        wmi_reg_write(ar9271->htc_device, AR9271_PHY_CAL, value);
    317        
     317
    318318        wmi_reg_clear_bit(ar9271->htc_device, AR9271_AGC_CONTROL,
    319319            AR9271_AGC_CONTROL_NF_CALIB_EN);
    320        
     320
    321321        wmi_reg_clear_bit(ar9271->htc_device, AR9271_AGC_CONTROL,
    322322            AR9271_AGC_CONTROL_NF_NOT_UPDATE);
    323        
     323
    324324        wmi_reg_set_bit(ar9271->htc_device, AR9271_AGC_CONTROL,
    325325            AR9271_AGC_CONTROL_NF_CALIB);
    326        
     326
    327327        errno_t rc = hw_read_wait(ar9271, AR9271_AGC_CONTROL,
    328328            AR9271_AGC_CONTROL_NF_CALIB, 0);
     
    331331                return rc;
    332332        }
    333        
     333
    334334        wmi_reg_set_bit(ar9271->htc_device, AR9271_AGC_CONTROL,
    335335            AR9271_AGC_CONTROL_NF_CALIB_EN);
    336        
     336
    337337        wmi_reg_clear_bit(ar9271->htc_device, AR9271_AGC_CONTROL,
    338338            AR9271_AGC_CONTROL_NF_NOT_UPDATE);
    339        
     339
    340340        wmi_reg_set_bit(ar9271->htc_device, AR9271_AGC_CONTROL,
    341341            AR9271_AGC_CONTROL_NF_CALIB);
    342        
     342
    343343        return EOK;
    344344}
     
    349349        if ((freq < IEEE80211_FIRST_FREQ) || (freq > IEEE80211_MAX_FREQ))
    350350                return EINVAL;
    351        
     351
    352352        /* Not supported channel frequency. */
    353353        if ((freq - IEEE80211_FIRST_FREQ) % IEEE80211_CHANNEL_GAP != 0)
    354354                return EINVAL;
    355        
     355
    356356        uint32_t tx_control;
    357357        wmi_reg_read(ar9271->htc_device, AR9271_PHY_CCK_TX_CTRL, &tx_control);
    358358        wmi_reg_write(ar9271->htc_device, AR9271_PHY_CCK_TX_CTRL,
    359359            tx_control & ~AR9271_PHY_CCK_TX_CTRL_JAPAN);
    360        
     360
    361361        /* Some magic here. */
    362362        uint32_t synth_ctl;
     
    365365        uint32_t channel_select = (freq * 0x10000) / 15;
    366366        synth_ctl = synth_ctl | (1 << 29) | (1 << 28) | channel_select;
    367        
     367
    368368        wmi_reg_write(ar9271->htc_device, AR9271_PHY_SYNTH_CONTROL, synth_ctl);
    369        
     369
    370370        ieee80211_report_current_freq(ar9271->ieee80211_dev, freq);
    371        
     371
    372372        return EOK;
    373373}
     
    376376{
    377377        wmi_reg_write(ar9271->htc_device, AR9271_PHY_RFBUS_KILL, 0x1);
    378        
     378
    379379        errno_t rc = hw_read_wait(ar9271, AR9271_PHY_RFBUS_GRANT, 0x1, 0x1);
    380380        if (rc != EOK) {
     
    382382                return rc;
    383383        }
    384        
     384
    385385        rc = hw_set_freq(ar9271, freq);
    386386        if (rc != EOK) {
     
    388388                return rc;
    389389        }
    390        
     390
    391391        rc = hw_activate_phy(ar9271);
    392392        if (rc != EOK) {
     
    394394                return rc;
    395395        }
    396        
     396
    397397        udelay(1000);
    398398        wmi_reg_write(ar9271->htc_device, AR9271_PHY_RFBUS_KILL, 0x0);
    399        
     399
    400400        rc = hw_noise_floor_calibration(ar9271);
    401401        if (rc != EOK) {
     
    403403                return rc;
    404404        }
    405        
     405
    406406        return EOK;
    407407}
     
    410410{
    411411        uint32_t additional_bits = 0;
    412        
     412
    413413        if (assoc)
    414414                additional_bits |= AR9271_RX_FILTER_MYBEACON;
    415415        else
    416416                additional_bits |= AR9271_RX_FILTER_BEACON;
    417        
     417
    418418        uint32_t filter_bits = AR9271_RX_FILTER_UNI |
    419419            AR9271_RX_FILTER_MULTI | AR9271_RX_FILTER_BROAD |
    420420            additional_bits;
    421        
     421
    422422        wmi_reg_write(ar9271->htc_device, AR9271_RX_FILTER, filter_bits);
    423        
     423
    424424        return EOK;
    425425}
     
    428428{
    429429        ieee80211_dev_t *ieee80211_dev = ar9271->ieee80211_dev;
    430        
     430
    431431        nic_address_t bssid;
    432432        ieee80211_query_bssid(ieee80211_dev, &bssid);
    433        
     433
    434434        uint32_t *first_4bytes = (uint32_t *) &bssid.address;
    435435        uint16_t *last_2bytes = (uint16_t *) &bssid.address[4];
    436        
     436
    437437        wmi_reg_write(ar9271->htc_device, AR9271_BSSID0,
    438438            uint32_t_le2host(*first_4bytes));
    439        
     439
    440440        wmi_reg_write(ar9271->htc_device, AR9271_BSSID1,
    441441            uint16_t_le2host(*last_2bytes) |
    442442            ((ieee80211_get_aid(ieee80211_dev) & 0x3fff) << 16));
    443        
     443
    444444        return EOK;
    445445}
     
    449449        wmi_reg_write(ar9271->htc_device, AR9271_COMMAND,
    450450            AR9271_COMMAND_RX_ENABLE);
    451        
     451
    452452        errno_t rc = hw_set_rx_filter(ar9271, false);
    453453        if (rc != EOK) {
     
    455455                return rc;
    456456        }
    457        
     457
    458458        wmi_reg_write(ar9271->htc_device, AR9271_MULTICAST_FILTER1, ~0);
    459459        wmi_reg_write(ar9271->htc_device, AR9271_MULTICAST_FILTER2, ~0);
    460        
     460
    461461        /* Disable RX blocking. */
    462462        wmi_reg_clear_bit(ar9271->htc_device, AR9271_DIAG, (0x20 | 0x02000000));
    463        
     463
    464464        return EOK;
    465465}
     
    469469        /* Some magic here (set for 2GHz channels). But VERY important :-) */
    470470        uint32_t pll = (0x5 << 10) | 0x2c;
    471        
     471
    472472        wmi_reg_write(ar9271->htc_device, AR9271_RTC_PLL_CONTROL, pll);
    473        
     473
    474474        wmi_reg_write(ar9271->htc_device, AR9271_RTC_SLEEP_CLOCK,
    475475            AR9271_RTC_SLEEP_CLOCK_FORCE_DERIVED);
    476476        wmi_reg_set_bit(ar9271->htc_device, AR9271_RTC_FORCE_WAKE,
    477477            AR9271_RTC_FORCE_WAKE_ENABLE);
    478        
     478
    479479        return EOK;
    480480}
     
    484484        uint32_t reg_offset;
    485485        uint32_t reg_value;
    486        
     486
    487487        size_t size = ARRAY_SIZE(ar9271_2g_mode_array);
    488        
     488
    489489        for (size_t i = 0; i < size; i++) {
    490490                reg_offset = ar9271_2g_mode_array[i][0];
     
    492492                wmi_reg_write(ar9271->htc_device, reg_offset, reg_value);
    493493        }
    494        
     494
    495495        size = ARRAY_SIZE(ar9271_2g_tx_array);
    496        
     496
    497497        for (size_t i = 0; i < size; i++) {
    498498                reg_offset = ar9271_2g_tx_array[i][0];
     
    500500                wmi_reg_write(ar9271->htc_device, reg_offset, reg_value);
    501501        }
    502        
     502
    503503        size = ARRAY_SIZE(ar9271_init_array);
    504        
     504
    505505        for (size_t i = 0; i < size; i++) {
    506506                reg_offset = ar9271_init_array[i][0];
     
    522522        wmi_reg_set_bit(ar9271->htc_device, AR9271_AGC_CONTROL,
    523523            AR9271_AGC_CONTROL_CALIB);
    524        
     524
    525525        errno_t rc = hw_read_wait(ar9271, AR9271_AGC_CONTROL,
    526526            AR9271_AGC_CONTROL_CALIB, 0);
     
    529529                return rc;
    530530        }
    531        
     531
    532532        wmi_reg_set_bit(ar9271->htc_device, AR9271_ADC_CONTROL,
    533533            AR9271_ADC_CONTROL_OFF_PWDADC);
     
    536536        wmi_reg_clear_bit(ar9271->htc_device, AR9271_AGC_CONTROL,
    537537            AR9271_AGC_CONTROL_TX_CALIB);
    538        
     538
    539539        return EOK;
    540540}
     
    544544        /* Set physical layer as deactivated. */
    545545        wmi_reg_write(ar9271->htc_device, AR9271_PHY_ACTIVE, 0);
    546        
     546
    547547        if(ar9271->starting_up) {
    548548                wmi_reg_write(ar9271->htc_device,
    549549                    AR9271_RESET_POWER_DOWN_CONTROL,
    550550                    AR9271_RADIO_RF_RESET);
    551                
     551
    552552                udelay(50);
    553553        }
    554        
     554
    555555        /* Cold reset when RX is enabled. */
    556556        uint32_t config_reg;
     
    558558        if (config_reg & AR9271_COMMAND_RX_ENABLE)
    559559                hw_set_reset(ar9271, true);
    560        
     560
    561561        errno_t rc = hw_init_pll(ar9271);
    562562        if (rc != EOK) {
     
    564564                return rc;
    565565        }
    566        
     566
    567567        udelay(500);
    568        
     568
    569569        wmi_reg_write(ar9271->htc_device, AR9271_CLOCK_CONTROL,
    570570            AR9271_MAX_CPU_CLOCK);
    571        
     571
    572572        udelay(100);
    573        
     573
    574574        if (ar9271->starting_up) {
    575575                wmi_reg_write(ar9271->htc_device,
    576576                    AR9271_RESET_POWER_DOWN_CONTROL,
    577577                    AR9271_GATE_MAC_CONTROL);
    578                
     578
    579579                udelay(50);
    580580        }
    581        
     581
    582582        hw_set_init_values(ar9271);
    583        
     583
    584584        /* Set physical layer mode. */
    585585        wmi_reg_write(ar9271->htc_device, AR9271_PHY_MODE,
    586586            AR9271_PHY_MODE_DYNAMIC);
    587        
     587
    588588        /* Reset device operating mode. */
    589589        rc = hw_reset_operating_mode(ar9271);
     
    592592                return rc;
    593593        }
    594        
     594
    595595        /* Set initial channel frequency. */
    596596        rc = hw_set_freq(ar9271, IEEE80211_FIRST_FREQ);
     
    599599                return rc;
    600600        }
    601        
     601
    602602        /* Initialize transmission queues. */
    603603        for (unsigned int i = 0; i < AR9271_QUEUES_COUNT; i++) {
     
    605605                    AR9271_QUEUE_BASE_MASK + (i << 2), 1 << i);
    606606        }
    607        
     607
    608608        /* Activate physical layer. */
    609609        rc = hw_activate_phy(ar9271);
     
    612612                return rc;
    613613        }
    614        
     614
    615615        /* Calibration. */
    616616        rc = hw_calibration(ar9271);
     
    619619                return rc;
    620620        }
    621        
     621
    622622        rc = hw_noise_floor_calibration(ar9271);
    623623        if (rc != EOK) {
     
    625625                return rc;
    626626        }
    627        
     627
    628628        /* Byteswap TX and RX data buffer words. */
    629629        wmi_reg_write(ar9271->htc_device, AR9271_CONFIG, 0xA);
    630        
     630
    631631        return EOK;
    632632}
     
    645645                return rc;
    646646        }
    647        
     647
    648648        rc = hw_init_led(ar9271);
    649649        if (rc != EOK) {
     
    651651                return rc;
    652652        }
    653        
     653
    654654        usb_log_info("HW initialization finished successfully.\n");
    655        
    656         return EOK;
    657 }
     655
     656        return EOK;
     657}
Note: See TracChangeset for help on using the changeset viewer.