# PHY
[PLATFORM]

Declaration of the PHY Drivers. More...

Collaboration diagram for PHY:

## Data Structures
struct | phy_channel_info
| Structure containing the information about the PHY channel that was used for this RX. More...
struct | phy_radar_pulse
| Structure containing information about radar pulse detected. More...
struct | phy_cfg_tag
| Structure containing the parameters of the PHY configuration. More...
## Defines
#define | PHY_UNUSED 0xFF
| Invalid value for some octet parameters reserved for the future.
#define | PHY_CFG_BUF_SIZE 16
| Maximum number of words in the configuration buffer.
#define | PHY_FREQ_5G 5000
| 5G lower bound freq
## Enumerations
enum | { PHY_PRIM, PHY_SEC }
| RF index definitions. More...
## Functions
void | phy_init (const struct phy_cfg_tag *config)
| Modem and Radio initialization function.
void | phy_reset (void)
| Resets some parts of the PHY.
void | phy_get_version (uint32_t *version_1, uint32_t *version_2)
| PHY version reading function.
void | phy_set_channel (const struct mac_chan_op *chan, uint8_t index)
| Set channel function.
void | phy_get_channel (struct phy_channel_info *info, uint8_t index)
| Get channel function.
void | phy_stop (void)
| PHY stop function.
uint32_t | phy_get_channel_switch_dur (void)
| Get maximum duration to set a new channel.
__INLINE int | phy_freq_to_channel (uint8_t band, uint16_t freq)
| Compute the channel number from its center frequency and its band.
__INLINE uint16_t | phy_channel_to_freq (uint8_t band, int channel)
| Compute the channel frequency from its number and band.
void | phy_mdm_isr (void)
| Modem interrupt service routine.
void | phy_rc_isr (void)
| RC interrupt service routine.
bool | phy_has_radar_pulse (int rd_idx)
| Indicates if the PHY has radar pulses available or not.
bool | phy_get_radar_pulse (int rd_idx, struct phy_radar_pulse *pulse)
| Read a radar pulse from the FIFO, and writes it to the buffer passed as parameter.
bool | phy_vht_supported (void)
| Return the VHT capability of the PHY.
bool | phy_he_supported (void)
| Return the HE capability of the PHY.
bool | phy_uf_supported (void)
| Return the unsupported HT frame handling capability of the PHY.
void | phy_uf_enable (bool enable)
| Configure the unsupported HT frame handling capability of the PHY.
bool | phy_ldpc_tx_supported (void)
| Return the LDPC TX capability of the PHY.
bool | phy_ldpc_rx_supported (void)
| Return the LDPC RX capability of the PHY.
bool | phy_bfmee_supported (void)
| Return the Beamformee capability of the PHY.
bool | phy_bfmer_supported (void)
| Return the Beamformer capability of the PHY.
bool | phy_mu_mimo_rx_supported (void)
| Return the MU-MIMO RX capability of the PHY.
bool | phy_mu_mimo_tx_supported (void)
| Return the MU-MIMO TX capability of the PHY.
void | phy_set_aid (uint16_t aid)
| Set the AID to the PHY, in order to allow correct operation of OFDMA-RX.
uint8_t | phy_get_bw (void)
| Return the supported BW of the PHY.
uint8_t | phy_get_nss (void)
| Return the NSS of the PHY.
uint8_t | phy_get_ntx (void)
| Return the NTX of the PHY.
uint8_t | phy_get_nrx (void)
| Return the NRX of the PHY.
uint8_t | phy_get_bfr_mem_size (void)
| Return the size of the BFMER memory in kBytes.
void | phy_get_rf_gain_idx (int8_t *power, uint8_t *idx)
| Get radio code to set a specific TX power Return the idx to use (set in policy table), to configure a specific TX power.
void | phy_get_rf_gain_capab (int8_t *max, int8_t *min)
| Get radio's transmission power capabilities.
uint8_t | phy_switch_antenna_paths (void)
| Switch paths connections.
## PHY INFO related definitions.
#define | PHY_INFO_BAND(__x) ((__x.info1) & 0x000000FF)
| Macro retrieving the band of the phy channel info.
#define | PHY_INFO_BW(__x) (((__x.info1) & 0x0000FF00) >> 8)
| Macro retrieving the bandwidth of the phy channel info.
#define | PHY_INFO_CHAN(__x) (((__x.info1) & 0xFFFF0000) >> 16)
| Macro retrieving the channel of the phy channel info.
#define | PHY_INFO_CENT_FREQ1(__x) ((__x.info2) & 0x0000FFFF)
| Macro retrieving the center frequency 1 of the phy channel info.
#define | PHY_INFO_CENT_FREQ2(__x) (((__x.info2) & 0xFFFF0000) >> 16)
| Macro retrieving the center frequency 2 of the phy channel info.

## Detailed Description

Declaration of the PHY Drivers.

## Define Documentation

#define PHY_INFO_BAND | ( | __x |  | ) | ((__x.info1) & 0x000000FF)

Macro retrieving the band of the phy channel info.

Parameters:

  `[in]` | __x | phy channel info 1 value.

Definition at line 55 of file phy.h.

Referenced by vif_mgmt_get_band().

#define PHY_INFO_BW | ( | __x |  | ) | (((__x.info1) & 0x0000FF00) >> 8)

Macro retrieving the bandwidth of the phy channel info.

Parameters:

  `[in]` | __x | phy channel info 1 value.

Definition at line 59 of file phy.h.

Referenced by bfr_get_bw().

#define PHY_INFO_CENT_FREQ1 | ( | __x |  | ) | ((__x.info2) & 0x0000FFFF)

Macro retrieving the center frequency 1 of the phy channel info.

Parameters:

  `[in]` | __x | phy channel info 2 value.

Definition at line 67 of file phy.h.

#define PHY_INFO_CENT_FREQ2 | ( | __x |  | ) | (((__x.info2) & 0xFFFF0000) >> 16)

Macro retrieving the center frequency 2 of the phy channel info.

Parameters:

  `[in]` | __x | phy channel info 2 value.

Definition at line 71 of file phy.h.

#define PHY_INFO_CHAN | ( | __x |  | ) | (((__x.info1) & 0xFFFF0000) >> 16)

Macro retrieving the channel of the phy channel info.

Parameters:

  `[in]` | __x | phy channel info 1 value.

Definition at line 63 of file phy.h.

## Enumeration Type Documentation

anonymous enum

RF index definitions.

Enumerator:

  PHY_PRIM | Primary radar detection chain (i.e for the operating channel).
  PHY_SEC | Secondary radar detection chain.

Definition at line 76 of file phy.h.

## Function Documentation

bool phy_bfmee_supported | ( | void |  | ) |

Return the Beamformee capability of the PHY.

Returns:
  true if Beamformee is supported by the PHY, false otherwise

Definition at line 797 of file phy_custom_rf.c.

Referenced by hal_machw_bfmee_support().

bool phy_bfmer_supported | ( | void |  | ) |

Return the Beamformer capability of the PHY.

Returns:
  true if Beamformer is supported by the PHY, false otherwise

Definition at line 802 of file phy_custom_rf.c.

Referenced by hal_machw_bfmer_support().

__INLINE uint16_t phy_channel_to_freq | ( | uint8_t | band,
|  | int | channel |
| ) |  |  |

Compute the channel frequency from its number and band.

Parameters:

  `[in]` | band | RF band (must be PHY_BAND_2G4 or PHY_BAND_5G)
  `[in]` | channel | Channel number

Returns:
  The channel frequency, 0 if not found

Definition at line 230 of file phy.h.

References PHY_BAND_2G4, PHY_BAND_5G, and PHY_FREQ_5G.

Referenced by me_extract_csa(), me_vht_bandwidth_parse(), scanu_scan_frame_handler(), and tdls_check_tdls_channel_switch_request().

__INLINE int phy_freq_to_channel | ( | uint8_t | band,
|  | uint16_t | freq |
| ) |  |  |

Compute the channel number from its center frequency and its band.

Parameters:

  `[in]` | band | RF band (must be PHY_BAND_2G4 or PHY_BAND_5G)
  `[in]` | freq | Center frequency of the channel

Returns:
  The channel number, 0 if not found

Definition at line 204 of file phy.h.

References PHY_BAND_2G4, PHY_BAND_5G, and PHY_FREQ_5G.

Referenced by me_add_ie_ht_oper(), me_build_associate_req(), me_extract_country_reg(), and txl_frame_send_tdls_channel_switch_req_frame().

uint8_t phy_get_bfr_mem_size | ( | void |  | ) |

Return the size of the BFMER memory in kBytes.

Returns:
  The size of the BFMER memory in kilobytes

Definition at line 866 of file phy_custom_rf.c.

uint8_t phy_get_bw | ( | void |  | ) |

Return the supported BW of the PHY.

Returns:
  0: BW20MHZ, 1: BW40MHZ, 2: BW80MHZ

Definition at line 845 of file phy_custom_rf.c.

void phy_get_channel | ( | struct phy_channel_info * | info,
|  | uint8_t | index |
| ) |  |  |

Get channel function.

This function is called when the MAC stack needs to get the information on the channel on which the radio is currently locked.

Parameters:

  `[out]` | info | Pointer on the phy_channel_info structure used to return the information
  `[in]` | index | Index of the RF for which the channel has to be retrieved (PHY_PRIM or PHY_SEC)

Definition at line 706 of file phy_custom_rf.c.

References mac_chan_op::band, mac_chan_op::center1_freq, mac_chan_op::center2_freq, phy_env_tag::chan, D_ERR, D_PHY, dbg, phy_channel_info::info1, phy_channel_info::info2, phy_env, mac_chan_op::prim20_freq, and mac_chan_op::type.

Referenced by bfr_get_bw(), rxl_mpdu_transfer(), rxu_mgt_frame_ind(), and vif_mgmt_get_band().

uint32_t phy_get_channel_switch_dur | ( | void |  | ) |

Get maximum duration to set a new channel.

This function is used when scheduling multiple channel context.

Returns:
  Maximum duration, in ms, to configure a new channel.

Definition at line 724 of file phy_custom_rf.c.

uint8_t phy_get_nrx | ( | void |  | ) |

Return the NRX of the PHY.

Returns:
  Number of antenna supported for RX minus 1 (i.e. 0 means 1 antenna)

Definition at line 860 of file phy_custom_rf.c.

Referenced by hal_desc_get_rssi().

uint8_t phy_get_nss | ( | void |  | ) |

Return the NSS of the PHY.

Returns:
  Number of Spatial Streams supported by the PHY (start from 0, 0 is for 1 SS)

Definition at line 850 of file phy_custom_rf.c.

Referenced by me_config_req_handler(), and txl_frame_init().

uint8_t phy_get_ntx | ( | void |  | ) |

Return the NTX of the PHY.

Returns:
  Number of antenna supported for TX minus 1 (i.e. 0 means 1 antenna)

Definition at line 855 of file phy_custom_rf.c.

Referenced by bfr_is_frame_bf_compliant(), me_update_buffer_control(), txl_agg_hwdesc_init(), and txl_frame_init().

bool phy_get_radar_pulse | ( | int | rd_idx,
|  | struct phy_radar_pulse * | pulse |
| ) |  |  |

Read a radar pulse from the FIFO, and writes it to the buffer passed as parameter.

Parameters:

  `[in]` | rd_idx | Index of the radar detection chain that needs to be read (PHY_PRIM or PHY_SEC)
  `[out]` | pulse | Pointer to the pulse structure where to write to

Returns:
  true if a pulse has been written, false otherwise

Definition at line 738 of file phy_custom_rf.c.

References __RIU_RADARFIFO_ADDR, ASSERT_ERR, PHY_PRIM, phy_radar_pulse::pulse, and REG_PL_RD.

void phy_get_rf_gain_capab | ( | int8_t * | max,
|  | int8_t * | min |
| ) |  |  |

Get radio's transmission power capabilities.

Parameters:

  `[out]` | max | Maximum TX power for the radio (in dBm)
  `[out]` | min | Minimum TX power for the radio (in dBm)

Definition at line 878 of file phy_custom_rf.c.

Referenced by me_build_associate_req().

void phy_get_rf_gain_idx | ( | int8_t * | power,
|  | uint8_t * | idx |
| ) |  |  |

Get radio code to set a specific TX power Return the idx to use (set in policy table), to configure a specific TX power.

If the TX power requested is not possible, it should return idx to get the maximum TX power that do not exceed the request. In this case, power parameter should be updated to the actual TX power set.

Parameters:

  `[in,out]` | power | TX power (in dBm) to configure for the radio, (updated with the actual power set if request is not possible)
  `[out]` | idx | Idx to use in policy table to configure a tx power of <gain>

Definition at line 872 of file phy_custom_rf.c.

Referenced by tpc_get_vif_tx_power(), tpc_set_vif_tx_power(), and tpc_update_tx_power().

void phy_get_version | ( | uint32_t * | version_1,
|  | uint32_t * | version_2 |
| ) |  |  |

PHY version reading function.

This function returns the PHY version on two 32-bit words. The format of these two words is PHY dependent.

Parameters:

  `[out]` | version_1 | Pointer to the 1st version word
  `[out]` | version_2 | Pointer to the 2nd version word

Definition at line 672 of file phy_custom_rf.c.

Referenced by mm_version_req_handler().

bool phy_has_radar_pulse | ( | int | rd_idx | ) |

Indicates if the PHY has radar pulses available or not.

Parameters:

  `[in]` | rd_idx | Index of the radar detection chain that needs to be checked (PHY_PRIM or PHY_SEC)

Returns:
  true if pulse(s) is(are) available, false otherwise

Definition at line 730 of file phy_custom_rf.c.

References ASSERT_ERR, and PHY_PRIM.

bool phy_he_supported | ( | void |  | ) |

Return the HE capability of the PHY.

Returns:
  true if the HE is supported by the PHY, false otherwise

Definition at line 761 of file phy_custom_rf.c.

Referenced by hal_machw_he_support(), and mdm_init().

void phy_init | ( | const struct phy_cfg_tag * | config | ) |

Modem and Radio initialization function.

This function is called at platform reset and initializes modem, then radio.

Parameters:

  `[in]` | config | Pointer to the PHY parameters (used radio paths, other cfg)

Definition at line 620 of file phy_custom_rf.c.

References mac_chan_op::band, mac_chan_op::center1_freq, mac_chan_op::center2_freq, phy_env_tag::cfg, phy_env_tag::chan, phy_cfg_tag::parameters, PHY_BAND_5G, PHY_CHNL_BW_OTHER, phy_env, phy_hw_init(), PHY_UNUSED, mac_chan_op::prim20_freq, and mac_chan_op::type.

Referenced by mm_start_req_handler().

bool phy_ldpc_rx_supported | ( | void |  | ) |

Return the LDPC RX capability of the PHY.

Returns:
  true if the LDPC RX is supported by the PHY, false otherwise

Definition at line 792 of file phy_custom_rf.c.

bool phy_ldpc_tx_supported | ( | void |  | ) |

Return the LDPC TX capability of the PHY.

Returns:
  true if the LDPC TX is supported by the PHY, false otherwise

Definition at line 787 of file phy_custom_rf.c.

void phy_mdm_isr | ( | void |  | ) |

Modem interrupt service routine.

This function is called when a Modem interrupt is asserted to the interrupt controller

Definition at line 634 of file phy_custom_rf.c.

References uf_event_ind().

bool phy_mu_mimo_rx_supported | ( | void |  | ) |

Return the MU-MIMO RX capability of the PHY.

Returns:
  true if MU-MIMO RX is supported by the PHY, false otherwise

Definition at line 807 of file phy_custom_rf.c.

Referenced by hal_machw_mu_mimo_rx_support().

bool phy_mu_mimo_tx_supported | ( | void |  | ) |

Return the MU-MIMO TX capability of the PHY.

Returns:
  true if MU-MIMO TX is supported by the PHY, false otherwise

Definition at line 812 of file phy_custom_rf.c.

Referenced by hal_machw_mu_mimo_tx_support().

void phy_rc_isr | ( | void |  | ) |

RC interrupt service routine.

This function is called when a RC interrupt is asserted to the interrupt controller

Definition at line 651 of file phy_custom_rf.c.

References ASSERT_REC, crm_mdm_reset(), PHY_PRIM, PROF_RADAR_IRQ_CLR, PROF_RADAR_IRQ_SET, and rd_event_ind().

void phy_reset | ( | void |  | ) |

Resets some parts of the PHY.

This function is called upon a system reset during the recovery procedure.

void phy_set_aid | ( | uint16_t | aid | ) |

Set the AID to the PHY, in order to allow correct operation of OFDMA-RX.

Parameters:

  `[in]` | aid | Association ID assigned by the AP

Definition at line 836 of file phy_custom_rf.c.

Referenced by mm_set_vif_state_req_handler().

void phy_set_channel | ( | const struct mac_chan_op * | chan,
|  | uint8_t | index |
| ) |  |  |

Set channel function.

This function is called when the MAC stack needs to change the channel on which the radio is locked. The function is blocking until the PLL has locked on the new channel frequency.

Parameters:

  `[in]` | chan | Channel configuration
  `[in]` | index | Index of the RF for which the channel has to be set (PHY_PRIM operating (primary RF)), 1: secondary RF (PHY_SEC used for additional radar detection). This parameter is reserved if no secondary RF is available in the system

Definition at line 679 of file phy_custom_rf.c.

References mac_chan_op::band, mac_chan_op::center1_freq, mac_chan_op::center2_freq, phy_env_tag::chan, D_ERR, D_INF, D_PHY, dbg, mac_chan_op::flags, phy_env, phy_hw_set_channel(), mac_chan_op::prim20_freq, and mac_chan_op::type.

Referenced by chan_check_chan(), chan_switch_channel(), mm_set_channel_req_handler(), and mm_start_req_handler().

void phy_stop | ( | void |  | ) |

PHY stop function.

This function is called when the MAC stack needs to stop the PHY. It puts back the MAC HW to the IDLE state

Definition at line 718 of file phy_custom_rf.c.

References D_ERR, dbg, and HW_IDLE.

Referenced by mm_reset_req_handler().

uint8_t phy_switch_antenna_paths | ( | void |  | ) |

Switch paths connections.

Returns:
  Value of PATHMUX register

Definition at line 891 of file phy_custom_rf.c.

References PROF_ANT_DIV_SWITCH_CLR, and PROF_ANT_DIV_SWITCH_SET.

void phy_uf_enable | ( | bool | enable | ) |

Configure the unsupported HT frame handling capability of the PHY.

Parameters:

  `[in]` | enable | Enable/Disable unsupported HT frame handling feature

Definition at line 779 of file phy_custom_rf.c.

Referenced by me_config_monitor_req_handler().

bool phy_uf_supported | ( | void |  | ) |

Return the unsupported HT frame handling capability of the PHY.

Returns:
  true if the UF is supported by the PHY, false otherwise

Definition at line 770 of file phy_custom_rf.c.

Referenced by me_config_monitor_req_handler(), and mm_version_req_handler().

bool phy_vht_supported | ( | void |  | ) |

Return the VHT capability of the PHY.

Returns:
  true if the VHT is supported by the PHY, false otherwise

Definition at line 752 of file phy_custom_rf.c.

References PHY_CHNL_BW_40.

Referenced by crm_clk_conf(), mdm_init(), and mm_version_req_handler().