| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /****************************************************************************** |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms of version 2 of the GNU General Public License as |
|---|
| 7 | | - * published by the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 10 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 11 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 12 | | - * more details. |
|---|
| 13 | | - * |
|---|
| 14 | | - * You should have received a copy of the GNU General Public License along with |
|---|
| 15 | | - * this program; if not, write to the Free Software Foundation, Inc., |
|---|
| 16 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA |
|---|
| 17 | | - * |
|---|
| 18 | | - * The full GNU General Public License is included in this distribution in the |
|---|
| 19 | | - * file called LICENSE. |
|---|
| 20 | 5 | * |
|---|
| 21 | 6 | * Contact Information: |
|---|
| 22 | 7 | * Intel Linux Wireless <ilw@linux.intel.com> |
|---|
| .. | .. |
|---|
| 32 | 17 | #include <linux/sched.h> |
|---|
| 33 | 18 | #include <linux/skbuff.h> |
|---|
| 34 | 19 | #include <linux/netdevice.h> |
|---|
| 20 | +#include <linux/units.h> |
|---|
| 35 | 21 | #include <net/mac80211.h> |
|---|
| 36 | 22 | #include <linux/etherdevice.h> |
|---|
| 37 | 23 | #include <asm/unaligned.h> |
|---|
| .. | .. |
|---|
| 39 | 25 | #include "common.h" |
|---|
| 40 | 26 | #include "4965.h" |
|---|
| 41 | 27 | |
|---|
| 42 | | -/** |
|---|
| 28 | +/* |
|---|
| 43 | 29 | * il_verify_inst_sparse - verify runtime uCode image in card vs. host, |
|---|
| 44 | 30 | * using sample data 100 bytes apart. If these sample points are good, |
|---|
| 45 | 31 | * it's a pretty good bet that everything between them is good, too. |
|---|
| .. | .. |
|---|
| 71 | 57 | return ret; |
|---|
| 72 | 58 | } |
|---|
| 73 | 59 | |
|---|
| 74 | | -/** |
|---|
| 60 | +/* |
|---|
| 75 | 61 | * il4965_verify_inst_full - verify runtime uCode image in card vs. host, |
|---|
| 76 | 62 | * looking at all data. |
|---|
| 77 | 63 | */ |
|---|
| .. | .. |
|---|
| 110 | 96 | return ret; |
|---|
| 111 | 97 | } |
|---|
| 112 | 98 | |
|---|
| 113 | | -/** |
|---|
| 99 | +/* |
|---|
| 114 | 100 | * il4965_verify_ucode - determine which instruction image is in SRAM, |
|---|
| 115 | 101 | * and verify its contents |
|---|
| 116 | 102 | */ |
|---|
| .. | .. |
|---|
| 306 | 292 | return 0; |
|---|
| 307 | 293 | } |
|---|
| 308 | 294 | |
|---|
| 309 | | -/** |
|---|
| 295 | +/* |
|---|
| 310 | 296 | * il4965_load_bsm - Load bootstrap instructions |
|---|
| 311 | 297 | * |
|---|
| 312 | 298 | * BSM operation: |
|---|
| .. | .. |
|---|
| 416 | 402 | return 0; |
|---|
| 417 | 403 | } |
|---|
| 418 | 404 | |
|---|
| 419 | | -/** |
|---|
| 405 | +/* |
|---|
| 420 | 406 | * il4965_set_ucode_ptrs - Set uCode address location |
|---|
| 421 | 407 | * |
|---|
| 422 | 408 | * Tell initialization uCode where to find runtime uCode. |
|---|
| .. | .. |
|---|
| 430 | 416 | { |
|---|
| 431 | 417 | dma_addr_t pinst; |
|---|
| 432 | 418 | dma_addr_t pdata; |
|---|
| 433 | | - int ret = 0; |
|---|
| 434 | 419 | |
|---|
| 435 | 420 | /* bits 35:4 for 4965 */ |
|---|
| 436 | 421 | pinst = il->ucode_code.p_addr >> 4; |
|---|
| .. | .. |
|---|
| 447 | 432 | il->ucode_code.len | BSM_DRAM_INST_LOAD); |
|---|
| 448 | 433 | D_INFO("Runtime uCode pointers are set.\n"); |
|---|
| 449 | 434 | |
|---|
| 450 | | - return ret; |
|---|
| 435 | + return 0; |
|---|
| 451 | 436 | } |
|---|
| 452 | 437 | |
|---|
| 453 | | -/** |
|---|
| 438 | +/* |
|---|
| 454 | 439 | * il4965_init_alive_start - Called after N_ALIVE notification received |
|---|
| 455 | 440 | * |
|---|
| 456 | 441 | * Called after N_ALIVE notification received from "initialize" uCode. |
|---|
| .. | .. |
|---|
| 577 | 562 | sign = -sign; |
|---|
| 578 | 563 | denom = -denom; |
|---|
| 579 | 564 | } |
|---|
| 580 | | - *res = 1; |
|---|
| 581 | 565 | *res = ((num * 2 + denom) / (denom * 2)) * sign; |
|---|
| 582 | 566 | |
|---|
| 583 | 567 | return 1; |
|---|
| 584 | 568 | } |
|---|
| 585 | 569 | |
|---|
| 586 | | -/** |
|---|
| 570 | +/* |
|---|
| 587 | 571 | * il4965_get_voltage_compensation - Power supply voltage comp for txpower |
|---|
| 588 | 572 | * |
|---|
| 589 | 573 | * Determines power supply voltage compensation for txpower calculations. |
|---|
| .. | .. |
|---|
| 670 | 654 | } |
|---|
| 671 | 655 | } |
|---|
| 672 | 656 | |
|---|
| 673 | | -/** |
|---|
| 657 | +/* |
|---|
| 674 | 658 | * il4965_interpolate_chan - Interpolate factory measurements for one channel |
|---|
| 675 | 659 | * |
|---|
| 676 | 660 | * Interpolates factory measurements from the two sample channels within a |
|---|
| .. | .. |
|---|
| 1120 | 1104 | /* get current temperature (Celsius) */ |
|---|
| 1121 | 1105 | current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN); |
|---|
| 1122 | 1106 | current_temp = min(il->temperature, IL_TX_POWER_TEMPERATURE_MAX); |
|---|
| 1123 | | - current_temp = KELVIN_TO_CELSIUS(current_temp); |
|---|
| 1107 | + current_temp = kelvin_to_celsius(current_temp); |
|---|
| 1124 | 1108 | |
|---|
| 1125 | 1109 | /* select thermal txpower adjustment params, based on channel group |
|---|
| 1126 | 1110 | * (same frequency group used for mimo txatten adjustment) */ |
|---|
| .. | .. |
|---|
| 1247 | 1231 | return 0; |
|---|
| 1248 | 1232 | } |
|---|
| 1249 | 1233 | |
|---|
| 1250 | | -/** |
|---|
| 1234 | +/* |
|---|
| 1251 | 1235 | * il4965_send_tx_power - Configure the TXPOWER level user limit |
|---|
| 1252 | 1236 | * |
|---|
| 1253 | 1237 | * Uses the active RXON for channel, band, and characteristics (ht40, high) |
|---|
| .. | .. |
|---|
| 1296 | 1280 | struct il4965_rxon_assoc_cmd rxon_assoc; |
|---|
| 1297 | 1281 | const struct il_rxon_cmd *rxon1 = &il->staging; |
|---|
| 1298 | 1282 | const struct il_rxon_cmd *rxon2 = &il->active; |
|---|
| 1283 | + |
|---|
| 1284 | + lockdep_assert_held(&il->mutex); |
|---|
| 1299 | 1285 | |
|---|
| 1300 | 1286 | if (rxon1->flags == rxon2->flags && |
|---|
| 1301 | 1287 | rxon1->filter_flags == rxon2->filter_flags && |
|---|
| .. | .. |
|---|
| 1542 | 1528 | return il_send_cmd_pdu(il, C_CHANNEL_SWITCH, sizeof(cmd), &cmd); |
|---|
| 1543 | 1529 | } |
|---|
| 1544 | 1530 | |
|---|
| 1545 | | -/** |
|---|
| 1531 | +/* |
|---|
| 1546 | 1532 | * il4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array |
|---|
| 1547 | 1533 | */ |
|---|
| 1548 | 1534 | static void |
|---|
| .. | .. |
|---|
| 1567 | 1553 | bc_ent; |
|---|
| 1568 | 1554 | } |
|---|
| 1569 | 1555 | |
|---|
| 1570 | | -/** |
|---|
| 1556 | +/* |
|---|
| 1571 | 1557 | * il4965_hw_get_temperature - return the calibrated temperature (in Kelvin) |
|---|
| 1572 | | - * @stats: Provides the temperature reading from the uCode |
|---|
| 1573 | 1558 | * |
|---|
| 1574 | 1559 | * A return of <0 indicates bogus data in the stats |
|---|
| 1575 | 1560 | */ |
|---|
| .. | .. |
|---|
| 1624 | 1609 | temperature = |
|---|
| 1625 | 1610 | (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; |
|---|
| 1626 | 1611 | |
|---|
| 1627 | | - D_TEMP("Calibrated temperature: %dK, %dC\n", temperature, |
|---|
| 1628 | | - KELVIN_TO_CELSIUS(temperature)); |
|---|
| 1612 | + D_TEMP("Calibrated temperature: %dK, %ldC\n", temperature, |
|---|
| 1613 | + kelvin_to_celsius(temperature)); |
|---|
| 1629 | 1614 | |
|---|
| 1630 | 1615 | return temperature; |
|---|
| 1631 | 1616 | } |
|---|
| .. | .. |
|---|
| 1633 | 1618 | /* Adjust Txpower only if temperature variance is greater than threshold. */ |
|---|
| 1634 | 1619 | #define IL_TEMPERATURE_THRESHOLD 3 |
|---|
| 1635 | 1620 | |
|---|
| 1636 | | -/** |
|---|
| 1621 | +/* |
|---|
| 1637 | 1622 | * il4965_is_temp_calib_needed - determines if new calibration is needed |
|---|
| 1638 | 1623 | * |
|---|
| 1639 | 1624 | * If the temperature changed has changed sufficiently, then a recalibration |
|---|
| .. | .. |
|---|
| 1684 | 1669 | |
|---|
| 1685 | 1670 | if (il->temperature != temp) { |
|---|
| 1686 | 1671 | if (il->temperature) |
|---|
| 1687 | | - D_TEMP("Temperature changed " "from %dC to %dC\n", |
|---|
| 1688 | | - KELVIN_TO_CELSIUS(il->temperature), |
|---|
| 1689 | | - KELVIN_TO_CELSIUS(temp)); |
|---|
| 1672 | + D_TEMP("Temperature changed " "from %ldC to %ldC\n", |
|---|
| 1673 | + kelvin_to_celsius(il->temperature), |
|---|
| 1674 | + kelvin_to_celsius(temp)); |
|---|
| 1690 | 1675 | else |
|---|
| 1691 | | - D_TEMP("Temperature " "initialized to %dC\n", |
|---|
| 1692 | | - KELVIN_TO_CELSIUS(temp)); |
|---|
| 1676 | + D_TEMP("Temperature " "initialized to %ldC\n", |
|---|
| 1677 | + kelvin_to_celsius(temp)); |
|---|
| 1693 | 1678 | } |
|---|
| 1694 | 1679 | |
|---|
| 1695 | 1680 | il->temperature = temp; |
|---|