iPXE
Data Structures | Functions | Variables
ath5k_initvals.c File Reference
#include <unistd.h>
#include "ath5k.h"
#include "reg.h"
#include "base.h"

Go to the source code of this file.

Data Structures

struct  ath5k_ini
 
struct  ath5k_ini_mode
 

Functions

 FILE_LICENCE (MIT)
 
 FILE_SECBOOT (FORBIDDEN)
 
static void ath5k_hw_ini_registers (struct ath5k_hw *ah, unsigned int size, const struct ath5k_ini *ini_regs, int change_channel)
 
static void ath5k_hw_ini_mode_registers (struct ath5k_hw *ah, unsigned int size, const struct ath5k_ini_mode *ini_mode, u8 mode)
 
int ath5k_hw_write_initvals (struct ath5k_hw *ah, u8 mode, int change_channel)
 

Variables

static const struct ath5k_ini ar5210_ini []
 
static const struct ath5k_ini ar5211_ini []
 
static const struct ath5k_ini_mode ar5211_ini_mode []
 
static const struct ath5k_ini ar5212_ini_common_start []
 
static const struct ath5k_ini_mode ar5212_ini_mode_start []
 
static const struct ath5k_ini_mode rf5111_ini_mode_end []
 
static const struct ath5k_ini rf5111_ini_common_end []
 
static const struct ath5k_ini_mode rf5112_ini_mode_end []
 
static const struct ath5k_ini rf5112_ini_common_end []
 
static const struct ath5k_ini_mode rf5413_ini_mode_end []
 
static const struct ath5k_ini rf5413_ini_common_end []
 
static const struct ath5k_ini_mode rf2413_ini_mode_end []
 
static const struct ath5k_ini rf2413_ini_common_end []
 
static const struct ath5k_ini_mode rf2425_ini_mode_end []
 
static const struct ath5k_ini rf2425_ini_common_end []
 
static const struct ath5k_ini rf5111_ini_bbgain []
 
static const struct ath5k_ini rf5112_ini_bbgain []
 

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( MIT  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( FORBIDDEN  )

◆ ath5k_hw_ini_registers()

static void ath5k_hw_ini_registers ( struct ath5k_hw ah,
unsigned int  size,
const struct ath5k_ini ini_regs,
int  change_channel 
)
static

Definition at line 1378 of file ath5k_initvals.c.

1380 {
1381  unsigned int i;
1382 
1383  /* Write initial registers */
1384  for (i = 0; i < size; i++) {
1385  /* On channel change there is
1386  * no need to mess with PCU */
1387  if (change_channel &&
1388  ini_regs[i].ini_register >= AR5K_PCU_MIN &&
1389  ini_regs[i].ini_register <= AR5K_PCU_MAX)
1390  continue;
1391 
1392  switch (ini_regs[i].ini_mode) {
1393  case AR5K_INI_READ:
1394  /* Cleared on read */
1395  ath5k_hw_reg_read(ah, ini_regs[i].ini_register);
1396  break;
1397  case AR5K_INI_WRITE:
1398  default:
1399  AR5K_REG_WAIT(i);
1400  ath5k_hw_reg_write(ah, ini_regs[i].ini_value,
1401  ini_regs[i].ini_register);
1402  }
1403  }
1404 }
#define AR5K_REG_WAIT(_i)
Definition: ath5k.h:135
uint16_t size
Buffer size.
Definition: dwmac.h:14
static void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
Definition: ath5k.h:1224
uint8_t ah
Definition: registers.h:85
static u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
Definition: ath5k.h:1216
#define AR5K_PCU_MIN
Definition: reg.h:1118
#define AR5K_PCU_MAX
Definition: reg.h:1119

References ah, ath5k_ini::AR5K_INI_READ, ath5k_ini::AR5K_INI_WRITE, AR5K_PCU_MAX, AR5K_PCU_MIN, AR5K_REG_WAIT, ath5k_hw_reg_read(), ath5k_hw_reg_write(), ath5k_ini::ini_mode, ath5k_ini::ini_register, ath5k_ini::ini_value, and size.

Referenced by ath5k_hw_write_initvals().

◆ ath5k_hw_ini_mode_registers()

static void ath5k_hw_ini_mode_registers ( struct ath5k_hw ah,
unsigned int  size,
const struct ath5k_ini_mode ini_mode,
u8  mode 
)
static

Definition at line 1406 of file ath5k_initvals.c.

1409 {
1410  unsigned int i;
1411 
1412  for (i = 0; i < size; i++) {
1413  AR5K_REG_WAIT(i);
1414  ath5k_hw_reg_write(ah, ini_mode[i].mode_value[mode],
1415  (u32)ini_mode[i].mode_register);
1416  }
1417 }
#define AR5K_REG_WAIT(_i)
Definition: ath5k.h:135
uint16_t mode
Acceleration mode.
Definition: ena.h:26
uint16_t size
Buffer size.
Definition: dwmac.h:14
static void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
Definition: ath5k.h:1224
uint8_t ah
Definition: registers.h:85
uint32_t u32
Definition: stdint.h:24

References ah, AR5K_REG_WAIT, ath5k_hw_reg_write(), ath5k_ini::ini_mode, mode, and size.

Referenced by ath5k_hw_write_initvals().

◆ ath5k_hw_write_initvals()

int ath5k_hw_write_initvals ( struct ath5k_hw ah,
u8  mode,
int  change_channel 
)

Definition at line 1419 of file ath5k_initvals.c.

1420 {
1421  /*
1422  * Write initial register settings
1423  */
1424 
1425  /* For AR5212 and combatible */
1426  if (ah->ah_version == AR5K_AR5212) {
1427 
1428  /* First set of mode-specific settings */
1432 
1433  /*
1434  * Write initial settings common for all modes
1435  */
1437  ar5212_ini_common_start, change_channel);
1438 
1439  /* Second set of mode-specific settings */
1440  switch (ah->ah_radio) {
1441  case AR5K_RF5111:
1442 
1446 
1449  rf5111_ini_common_end, change_channel);
1450 
1451  /* Baseband gain table */
1454  rf5111_ini_bbgain, change_channel);
1455 
1456  break;
1457  case AR5K_RF5112:
1458 
1462 
1465  rf5112_ini_common_end, change_channel);
1466 
1469  rf5112_ini_bbgain, change_channel);
1470 
1471  break;
1472  case AR5K_RF5413:
1473 
1477 
1480  rf5413_ini_common_end, change_channel);
1481 
1484  rf5112_ini_bbgain, change_channel);
1485 
1486  break;
1487  case AR5K_RF2316:
1488  case AR5K_RF2413:
1489 
1493 
1496  rf2413_ini_common_end, change_channel);
1497 
1498  /* Override settings from rf2413_ini_common_end */
1499  if (ah->ah_radio == AR5K_RF2316) {
1500  ath5k_hw_reg_write(ah, 0x00004000,
1501  AR5K_PHY_AGC);
1502  ath5k_hw_reg_write(ah, 0x081b7caa,
1503  0xa274);
1504  }
1505 
1508  rf5112_ini_bbgain, change_channel);
1509  break;
1510  case AR5K_RF2317:
1511  case AR5K_RF2425:
1512 
1516 
1519  rf2425_ini_common_end, change_channel);
1520 
1523  rf5112_ini_bbgain, change_channel);
1524  break;
1525  default:
1526  return -EINVAL;
1527 
1528  }
1529 
1530  /* For AR5211 */
1531  } else if (ah->ah_version == AR5K_AR5211) {
1532 
1533  /* AR5K_MODE_11B */
1534  if (mode > 2) {
1535  DBG("ath5k: unsupported channel mode %d\n", mode);
1536  return -EINVAL;
1537  }
1538 
1539  /* Mode-specific settings */
1542 
1543  /*
1544  * Write initial settings common for all modes
1545  */
1547  ar5211_ini, change_channel);
1548 
1549  /* AR5211 only comes with 5111 */
1550 
1551  /* Baseband gain table */
1553  rf5111_ini_bbgain, change_channel);
1554  /* For AR5210 (for mode settings check out ath5k_hw_reset_tx_queue) */
1555  } else if (ah->ah_version == AR5K_AR5210) {
1557  ar5210_ini, change_channel);
1558  }
1559 
1560  return 0;
1561 }
#define EINVAL
Invalid argument.
Definition: errno.h:429
static const struct ath5k_ini rf2413_ini_common_end[]
uint16_t mode
Acceleration mode.
Definition: ena.h:26
static const struct ath5k_ini_mode rf5111_ini_mode_end[]
static const struct ath5k_ini rf5112_ini_common_end[]
static const struct ath5k_ini_mode rf2425_ini_mode_end[]
static const struct ath5k_ini rf5111_ini_bbgain[]
#define AR5K_PHY_AGC
Definition: reg.h:1907
static const struct ath5k_ini_mode ar5212_ini_mode_start[]
static const struct ath5k_ini_mode rf2413_ini_mode_end[]
static const struct ath5k_ini ar5211_ini[]
static const struct ath5k_ini rf5112_ini_bbgain[]
static const struct ath5k_ini ar5210_ini[]
#define ARRAY_SIZE(x)
Definition: efx_common.h:43
static const struct ath5k_ini rf5111_ini_common_end[]
static void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
Definition: ath5k.h:1224
static const struct ath5k_ini ar5212_ini_common_start[]
static const struct ath5k_ini_mode rf5413_ini_mode_end[]
static const struct ath5k_ini_mode rf5112_ini_mode_end[]
uint8_t ah
Definition: registers.h:85
static const struct ath5k_ini rf5413_ini_common_end[]
static void ath5k_hw_ini_registers(struct ath5k_hw *ah, unsigned int size, const struct ath5k_ini *ini_regs, int change_channel)
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static const struct ath5k_ini_mode ar5211_ini_mode[]
static const struct ath5k_ini rf2425_ini_common_end[]
static void ath5k_hw_ini_mode_registers(struct ath5k_hw *ah, unsigned int size, const struct ath5k_ini_mode *ini_mode, u8 mode)

References ah, ar5210_ini, ar5211_ini, ar5211_ini_mode, ar5212_ini_common_start, ar5212_ini_mode_start, AR5K_AR5210, AR5K_AR5211, AR5K_AR5212, AR5K_PHY_AGC, AR5K_RF2316, AR5K_RF2317, AR5K_RF2413, AR5K_RF2425, AR5K_RF5111, AR5K_RF5112, AR5K_RF5413, ARRAY_SIZE, ath5k_hw_ini_mode_registers(), ath5k_hw_ini_registers(), ath5k_hw_reg_write(), DBG, EINVAL, mode, rf2413_ini_common_end, rf2413_ini_mode_end, rf2425_ini_common_end, rf2425_ini_mode_end, rf5111_ini_bbgain, rf5111_ini_common_end, rf5111_ini_mode_end, rf5112_ini_bbgain, rf5112_ini_common_end, rf5112_ini_mode_end, rf5413_ini_common_end, and rf5413_ini_mode_end.

Referenced by ath5k_hw_reset().

Variable Documentation

◆ ar5210_ini

const struct ath5k_ini ar5210_ini[]
static

Definition at line 57 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ ar5211_ini

const struct ath5k_ini ar5211_ini[]
static

Definition at line 269 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ ar5211_ini_mode

const struct ath5k_ini_mode ar5211_ini_mode[]
static

Definition at line 398 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ ar5212_ini_common_start

const struct ath5k_ini ar5212_ini_common_start[]
static

Definition at line 473 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ ar5212_ini_mode_start

const struct ath5k_ini_mode ar5212_ini_mode_start[]
static

Definition at line 686 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ rf5111_ini_mode_end

const struct ath5k_ini_mode rf5111_ini_mode_end[]
static

Definition at line 741 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ rf5111_ini_common_end

const struct ath5k_ini rf5111_ini_common_end[]
static
Initial value:
= {
{ AR5K_DCU_FP, 0x00000000, AR5K_INI_WRITE },
{ AR5K_PHY_AGC, 0x00000000, AR5K_INI_WRITE },
{ AR5K_PHY_ADC_CTL, 0x00022ffe, AR5K_INI_WRITE },
{ 0x983c, 0x00020100, AR5K_INI_WRITE },
{ AR5K_PHY_GAIN_OFFSET, 0x1284613c, AR5K_INI_WRITE },
{ AR5K_PHY_PAPD_PROBE, 0x00004883, AR5K_INI_WRITE },
{ 0x9940, 0x00000004, AR5K_INI_WRITE },
{ 0x9958, 0x000000ff, AR5K_INI_WRITE },
{ 0x9974, 0x00000000, AR5K_INI_WRITE },
{ AR5K_PHY_SPENDING, 0x00000018, AR5K_INI_WRITE },
{ AR5K_PHY_CCKTXCTL, 0x00000000, AR5K_INI_WRITE },
{ AR5K_PHY_CCK_CROSSCORR, 0xd03e6788, AR5K_INI_WRITE },
{ AR5K_PHY_DAG_CCK_CTL, 0x000001b5, AR5K_INI_WRITE },
{ 0xa23c, 0x13c889af, AR5K_INI_WRITE },
}
#define AR5K_PHY_SPENDING
Definition: reg.h:2486
#define AR5K_PHY_PAPD_PROBE
Definition: reg.h:2242
#define AR5K_PHY_AGC
Definition: reg.h:1907
#define AR5K_PHY_ADC_CTL
Definition: reg.h:1949
#define AR5K_DCU_FP
Definition: reg.h:803
#define AR5K_PHY_CCK_CROSSCORR
Definition: reg.h:2532
#define AR5K_PHY_DAG_CCK_CTL
Definition: reg.h:2552
#define AR5K_PHY_CCKTXCTL
Definition: reg.h:2523
#define AR5K_PHY_GAIN_OFFSET
Definition: reg.h:1992

Definition at line 773 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ rf5112_ini_mode_end

const struct ath5k_ini_mode rf5112_ini_mode_end[]
static

Definition at line 791 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ rf5112_ini_common_end

const struct ath5k_ini rf5112_ini_common_end[]
static
Initial value:
= {
{ AR5K_DCU_FP, 0x00000000, AR5K_INI_WRITE },
{ AR5K_PHY_AGC, 0x00000000, AR5K_INI_WRITE },
{ AR5K_PHY_ADC_CTL, 0x00022ffe, AR5K_INI_WRITE },
{ 0x983c, 0x00020100, AR5K_INI_WRITE },
{ AR5K_PHY_GAIN_OFFSET, 0x1284613c, AR5K_INI_WRITE },
{ AR5K_PHY_PAPD_PROBE, 0x00004882, AR5K_INI_WRITE },
{ 0x9940, 0x00000004, AR5K_INI_WRITE },
{ 0x9958, 0x000000ff, AR5K_INI_WRITE },
{ 0x9974, 0x00000000, AR5K_INI_WRITE },
{ AR5K_PHY_DAG_CCK_CTL, 0x000001b5, AR5K_INI_WRITE },
{ 0xa23c, 0x13c889af, AR5K_INI_WRITE },
}
#define AR5K_PHY_PAPD_PROBE
Definition: reg.h:2242
#define AR5K_PHY_AGC
Definition: reg.h:1907
#define AR5K_PHY_ADC_CTL
Definition: reg.h:1949
#define AR5K_DCU_FP
Definition: reg.h:803
#define AR5K_PHY_DAG_CCK_CTL
Definition: reg.h:2552
#define AR5K_PHY_GAIN_OFFSET
Definition: reg.h:1992

Definition at line 827 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ rf5413_ini_mode_end

const struct ath5k_ini_mode rf5413_ini_mode_end[]
static

Definition at line 842 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ rf5413_ini_common_end

const struct ath5k_ini rf5413_ini_common_end[]
static

Definition at line 906 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ rf2413_ini_mode_end

const struct ath5k_ini_mode rf2413_ini_mode_end[]
static

Definition at line 981 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ rf2413_ini_common_end

const struct ath5k_ini rf2413_ini_common_end[]
static

Definition at line 1017 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ rf2425_ini_mode_end

const struct ath5k_ini_mode rf2425_ini_mode_end[]
static

Definition at line 1103 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ rf2425_ini_common_end

const struct ath5k_ini rf2425_ini_common_end[]
static

Definition at line 1153 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ rf5111_ini_bbgain

const struct ath5k_ini rf5111_ini_bbgain[]
static

Definition at line 1239 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().

◆ rf5112_ini_bbgain

const struct ath5k_ini rf5112_ini_bbgain[]
static

Definition at line 1307 of file ath5k_initvals.c.

Referenced by ath5k_hw_write_initvals().