18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/****************************************************************************** 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Contact Information: 78c2ecf20Sopenharmony_ci * Intel Linux Wireless <ilw@linux.intel.com> 88c2ecf20Sopenharmony_ci * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci *****************************************************************************/ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifndef __il_4965_h__ 138c2ecf20Sopenharmony_ci#define __il_4965_h__ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cistruct il_rx_queue; 168c2ecf20Sopenharmony_cistruct il_rx_buf; 178c2ecf20Sopenharmony_cistruct il_rx_pkt; 188c2ecf20Sopenharmony_cistruct il_tx_queue; 198c2ecf20Sopenharmony_cistruct il_rxon_context; 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/* configuration for the _4965 devices */ 228c2ecf20Sopenharmony_ciextern struct il_cfg il4965_cfg; 238c2ecf20Sopenharmony_ciextern const struct il_ops il4965_ops; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ciextern struct il_mod_params il4965_mod_params; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* tx queue */ 288c2ecf20Sopenharmony_civoid il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid, 298c2ecf20Sopenharmony_ci int freed); 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci/* RXON */ 328c2ecf20Sopenharmony_civoid il4965_set_rxon_chain(struct il_priv *il); 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* uCode */ 358c2ecf20Sopenharmony_ciint il4965_verify_ucode(struct il_priv *il); 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* lib */ 388c2ecf20Sopenharmony_civoid il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status); 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_civoid il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); 418c2ecf20Sopenharmony_ciint il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq); 428c2ecf20Sopenharmony_ciint il4965_hw_nic_init(struct il_priv *il); 438c2ecf20Sopenharmony_ciint il4965_dump_fh(struct il_priv *il, char **buf, bool display); 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_civoid il4965_nic_config(struct il_priv *il); 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/* rx */ 488c2ecf20Sopenharmony_civoid il4965_rx_queue_restock(struct il_priv *il); 498c2ecf20Sopenharmony_civoid il4965_rx_replenish(struct il_priv *il); 508c2ecf20Sopenharmony_civoid il4965_rx_replenish_now(struct il_priv *il); 518c2ecf20Sopenharmony_civoid il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); 528c2ecf20Sopenharmony_ciint il4965_rxq_stop(struct il_priv *il); 538c2ecf20Sopenharmony_ciint il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum nl80211_band band); 548c2ecf20Sopenharmony_civoid il4965_rx_handle(struct il_priv *il); 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* tx */ 578c2ecf20Sopenharmony_civoid il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq); 588c2ecf20Sopenharmony_ciint il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, 598c2ecf20Sopenharmony_ci dma_addr_t addr, u16 len, u8 reset, u8 pad); 608c2ecf20Sopenharmony_ciint il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq); 618c2ecf20Sopenharmony_civoid il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, 628c2ecf20Sopenharmony_ci struct ieee80211_tx_info *info); 638c2ecf20Sopenharmony_ciint il4965_tx_skb(struct il_priv *il, 648c2ecf20Sopenharmony_ci struct ieee80211_sta *sta, 658c2ecf20Sopenharmony_ci struct sk_buff *skb); 668c2ecf20Sopenharmony_ciint il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, 678c2ecf20Sopenharmony_ci struct ieee80211_sta *sta, u16 tid, u16 * ssn); 688c2ecf20Sopenharmony_ciint il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, 698c2ecf20Sopenharmony_ci struct ieee80211_sta *sta, u16 tid); 708c2ecf20Sopenharmony_ciint il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id); 718c2ecf20Sopenharmony_ciint il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx); 728c2ecf20Sopenharmony_civoid il4965_hw_txq_ctx_free(struct il_priv *il); 738c2ecf20Sopenharmony_ciint il4965_txq_ctx_alloc(struct il_priv *il); 748c2ecf20Sopenharmony_civoid il4965_txq_ctx_reset(struct il_priv *il); 758c2ecf20Sopenharmony_civoid il4965_txq_ctx_stop(struct il_priv *il); 768c2ecf20Sopenharmony_civoid il4965_txq_set_sched(struct il_priv *il, u32 mask); 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/* 798c2ecf20Sopenharmony_ci * Acquire il->lock before calling this function ! 808c2ecf20Sopenharmony_ci */ 818c2ecf20Sopenharmony_civoid il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx); 828c2ecf20Sopenharmony_ci/** 838c2ecf20Sopenharmony_ci * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue 848c2ecf20Sopenharmony_ci * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed 858c2ecf20Sopenharmony_ci * @scd_retry: (1) Indicates queue will be used in aggregation mode 868c2ecf20Sopenharmony_ci * 878c2ecf20Sopenharmony_ci * NOTE: Acquire il->lock before calling this function ! 888c2ecf20Sopenharmony_ci */ 898c2ecf20Sopenharmony_civoid il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, 908c2ecf20Sopenharmony_ci int tx_fifo_id, int scd_retry); 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci/* scan */ 938c2ecf20Sopenharmony_ciint il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif); 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci/* station mgmt */ 968c2ecf20Sopenharmony_ciint il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif, 978c2ecf20Sopenharmony_ci bool add); 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci/* hcmd */ 1008c2ecf20Sopenharmony_ciint il4965_send_beacon_cmd(struct il_priv *il); 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#ifdef CONFIG_IWLEGACY_DEBUG 1038c2ecf20Sopenharmony_ciconst char *il4965_get_tx_fail_reason(u32 status); 1048c2ecf20Sopenharmony_ci#else 1058c2ecf20Sopenharmony_cistatic inline const char * 1068c2ecf20Sopenharmony_ciil4965_get_tx_fail_reason(u32 status) 1078c2ecf20Sopenharmony_ci{ 1088c2ecf20Sopenharmony_ci return ""; 1098c2ecf20Sopenharmony_ci} 1108c2ecf20Sopenharmony_ci#endif 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci/* station management */ 1138c2ecf20Sopenharmony_ciint il4965_alloc_bcast_station(struct il_priv *il); 1148c2ecf20Sopenharmony_ciint il4965_add_bssid_station(struct il_priv *il, const u8 *addr, u8 *sta_id_r); 1158c2ecf20Sopenharmony_ciint il4965_remove_default_wep_key(struct il_priv *il, 1168c2ecf20Sopenharmony_ci struct ieee80211_key_conf *key); 1178c2ecf20Sopenharmony_ciint il4965_set_default_wep_key(struct il_priv *il, 1188c2ecf20Sopenharmony_ci struct ieee80211_key_conf *key); 1198c2ecf20Sopenharmony_ciint il4965_restore_default_wep_keys(struct il_priv *il); 1208c2ecf20Sopenharmony_ciint il4965_set_dynamic_key(struct il_priv *il, 1218c2ecf20Sopenharmony_ci struct ieee80211_key_conf *key, u8 sta_id); 1228c2ecf20Sopenharmony_ciint il4965_remove_dynamic_key(struct il_priv *il, 1238c2ecf20Sopenharmony_ci struct ieee80211_key_conf *key, u8 sta_id); 1248c2ecf20Sopenharmony_civoid il4965_update_tkip_key(struct il_priv *il, 1258c2ecf20Sopenharmony_ci struct ieee80211_key_conf *keyconf, 1268c2ecf20Sopenharmony_ci struct ieee80211_sta *sta, u32 iv32, 1278c2ecf20Sopenharmony_ci u16 *phase1key); 1288c2ecf20Sopenharmony_ciint il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid); 1298c2ecf20Sopenharmony_ciint il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, 1308c2ecf20Sopenharmony_ci int tid, u16 ssn); 1318c2ecf20Sopenharmony_ciint il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, 1328c2ecf20Sopenharmony_ci int tid); 1338c2ecf20Sopenharmony_civoid il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt); 1348c2ecf20Sopenharmony_ciint il4965_update_bcast_stations(struct il_priv *il); 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci/* rate */ 1378c2ecf20Sopenharmony_cistatic inline u8 1388c2ecf20Sopenharmony_ciil4965_hw_get_rate(__le32 rate_n_flags) 1398c2ecf20Sopenharmony_ci{ 1408c2ecf20Sopenharmony_ci return le32_to_cpu(rate_n_flags) & 0xFF; 1418c2ecf20Sopenharmony_ci} 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci/* eeprom */ 1448c2ecf20Sopenharmony_civoid il4965_eeprom_get_mac(const struct il_priv *il, u8 * mac); 1458c2ecf20Sopenharmony_ciint il4965_eeprom_acquire_semaphore(struct il_priv *il); 1468c2ecf20Sopenharmony_civoid il4965_eeprom_release_semaphore(struct il_priv *il); 1478c2ecf20Sopenharmony_ciint il4965_eeprom_check_version(struct il_priv *il); 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci/* mac80211 handlers (for 4965) */ 1508c2ecf20Sopenharmony_civoid il4965_mac_tx(struct ieee80211_hw *hw, 1518c2ecf20Sopenharmony_ci struct ieee80211_tx_control *control, 1528c2ecf20Sopenharmony_ci struct sk_buff *skb); 1538c2ecf20Sopenharmony_ciint il4965_mac_start(struct ieee80211_hw *hw); 1548c2ecf20Sopenharmony_civoid il4965_mac_stop(struct ieee80211_hw *hw); 1558c2ecf20Sopenharmony_civoid il4965_configure_filter(struct ieee80211_hw *hw, 1568c2ecf20Sopenharmony_ci unsigned int changed_flags, 1578c2ecf20Sopenharmony_ci unsigned int *total_flags, u64 multicast); 1588c2ecf20Sopenharmony_ciint il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 1598c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, struct ieee80211_sta *sta, 1608c2ecf20Sopenharmony_ci struct ieee80211_key_conf *key); 1618c2ecf20Sopenharmony_civoid il4965_mac_update_tkip_key(struct ieee80211_hw *hw, 1628c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, 1638c2ecf20Sopenharmony_ci struct ieee80211_key_conf *keyconf, 1648c2ecf20Sopenharmony_ci struct ieee80211_sta *sta, u32 iv32, 1658c2ecf20Sopenharmony_ci u16 *phase1key); 1668c2ecf20Sopenharmony_ciint il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1678c2ecf20Sopenharmony_ci struct ieee80211_ampdu_params *params); 1688c2ecf20Sopenharmony_ciint il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1698c2ecf20Sopenharmony_ci struct ieee80211_sta *sta); 1708c2ecf20Sopenharmony_civoid 1718c2ecf20Sopenharmony_ciil4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1728c2ecf20Sopenharmony_ci struct ieee80211_channel_switch *ch_switch); 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_civoid il4965_led_enable(struct il_priv *il); 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci/* EEPROM */ 1778c2ecf20Sopenharmony_ci#define IL4965_EEPROM_IMG_SIZE 1024 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci/* 1808c2ecf20Sopenharmony_ci * uCode queue management definitions ... 1818c2ecf20Sopenharmony_ci * The first queue used for block-ack aggregation is #7 (4965 only). 1828c2ecf20Sopenharmony_ci * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7. 1838c2ecf20Sopenharmony_ci */ 1848c2ecf20Sopenharmony_ci#define IL49_FIRST_AMPDU_QUEUE 7 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci/* Sizes and addresses for instruction and data memory (SRAM) in 1878c2ecf20Sopenharmony_ci * 4965's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ 1888c2ecf20Sopenharmony_ci#define IL49_RTC_INST_LOWER_BOUND (0x000000) 1898c2ecf20Sopenharmony_ci#define IL49_RTC_INST_UPPER_BOUND (0x018000) 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci#define IL49_RTC_DATA_LOWER_BOUND (0x800000) 1928c2ecf20Sopenharmony_ci#define IL49_RTC_DATA_UPPER_BOUND (0x80A000) 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci#define IL49_RTC_INST_SIZE (IL49_RTC_INST_UPPER_BOUND - \ 1958c2ecf20Sopenharmony_ci IL49_RTC_INST_LOWER_BOUND) 1968c2ecf20Sopenharmony_ci#define IL49_RTC_DATA_SIZE (IL49_RTC_DATA_UPPER_BOUND - \ 1978c2ecf20Sopenharmony_ci IL49_RTC_DATA_LOWER_BOUND) 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci#define IL49_MAX_INST_SIZE IL49_RTC_INST_SIZE 2008c2ecf20Sopenharmony_ci#define IL49_MAX_DATA_SIZE IL49_RTC_DATA_SIZE 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci/* Size of uCode instruction memory in bootstrap state machine */ 2038c2ecf20Sopenharmony_ci#define IL49_MAX_BSM_SIZE BSM_SRAM_SIZE 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_cistatic inline int 2068c2ecf20Sopenharmony_ciil4965_hw_valid_rtc_data_addr(u32 addr) 2078c2ecf20Sopenharmony_ci{ 2088c2ecf20Sopenharmony_ci return (addr >= IL49_RTC_DATA_LOWER_BOUND && 2098c2ecf20Sopenharmony_ci addr < IL49_RTC_DATA_UPPER_BOUND); 2108c2ecf20Sopenharmony_ci} 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci/********************* START TEMPERATURE *************************************/ 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci/** 2158c2ecf20Sopenharmony_ci * 4965 temperature calculation. 2168c2ecf20Sopenharmony_ci * 2178c2ecf20Sopenharmony_ci * The driver must calculate the device temperature before calculating 2188c2ecf20Sopenharmony_ci * a txpower setting (amplifier gain is temperature dependent). The 2198c2ecf20Sopenharmony_ci * calculation uses 4 measurements, 3 of which (R1, R2, R3) are calibration 2208c2ecf20Sopenharmony_ci * values used for the life of the driver, and one of which (R4) is the 2218c2ecf20Sopenharmony_ci * real-time temperature indicator. 2228c2ecf20Sopenharmony_ci * 2238c2ecf20Sopenharmony_ci * uCode provides all 4 values to the driver via the "initialize alive" 2248c2ecf20Sopenharmony_ci * notification (see struct il4965_init_alive_resp). After the runtime uCode 2258c2ecf20Sopenharmony_ci * image loads, uCode updates the R4 value via stats notifications 2268c2ecf20Sopenharmony_ci * (see N_STATS), which occur after each received beacon 2278c2ecf20Sopenharmony_ci * when associated, or can be requested via C_STATS. 2288c2ecf20Sopenharmony_ci * 2298c2ecf20Sopenharmony_ci * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver 2308c2ecf20Sopenharmony_ci * must sign-extend to 32 bits before applying formula below. 2318c2ecf20Sopenharmony_ci * 2328c2ecf20Sopenharmony_ci * Formula: 2338c2ecf20Sopenharmony_ci * 2348c2ecf20Sopenharmony_ci * degrees Kelvin = ((97 * 259 * (R4 - R2) / (R3 - R1)) / 100) + 8 2358c2ecf20Sopenharmony_ci * 2368c2ecf20Sopenharmony_ci * NOTE: The basic formula is 259 * (R4-R2) / (R3-R1). The 97/100 is 2378c2ecf20Sopenharmony_ci * an additional correction, which should be centered around 0 degrees 2388c2ecf20Sopenharmony_ci * Celsius (273 degrees Kelvin). The 8 (3 percent of 273) compensates for 2398c2ecf20Sopenharmony_ci * centering the 97/100 correction around 0 degrees K. 2408c2ecf20Sopenharmony_ci * 2418c2ecf20Sopenharmony_ci * Add 273 to Kelvin value to find degrees Celsius, for comparing current 2428c2ecf20Sopenharmony_ci * temperature with factory-measured temperatures when calculating txpower 2438c2ecf20Sopenharmony_ci * settings. 2448c2ecf20Sopenharmony_ci */ 2458c2ecf20Sopenharmony_ci#define TEMPERATURE_CALIB_KELVIN_OFFSET 8 2468c2ecf20Sopenharmony_ci#define TEMPERATURE_CALIB_A_VAL 259 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci/* Limit range of calculated temperature to be between these Kelvin values */ 2498c2ecf20Sopenharmony_ci#define IL_TX_POWER_TEMPERATURE_MIN (263) 2508c2ecf20Sopenharmony_ci#define IL_TX_POWER_TEMPERATURE_MAX (410) 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci#define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \ 2538c2ecf20Sopenharmony_ci ((t) < IL_TX_POWER_TEMPERATURE_MIN || \ 2548c2ecf20Sopenharmony_ci (t) > IL_TX_POWER_TEMPERATURE_MAX) 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_civoid il4965_temperature_calib(struct il_priv *il); 2578c2ecf20Sopenharmony_ci/********************* END TEMPERATURE ***************************************/ 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci/********************* START TXPOWER *****************************************/ 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci/** 2628c2ecf20Sopenharmony_ci * 4965 txpower calculations rely on information from three sources: 2638c2ecf20Sopenharmony_ci * 2648c2ecf20Sopenharmony_ci * 1) EEPROM 2658c2ecf20Sopenharmony_ci * 2) "initialize" alive notification 2668c2ecf20Sopenharmony_ci * 3) stats notifications 2678c2ecf20Sopenharmony_ci * 2688c2ecf20Sopenharmony_ci * EEPROM data consists of: 2698c2ecf20Sopenharmony_ci * 2708c2ecf20Sopenharmony_ci * 1) Regulatory information (max txpower and channel usage flags) is provided 2718c2ecf20Sopenharmony_ci * separately for each channel that can possibly supported by 4965. 2728c2ecf20Sopenharmony_ci * 40 MHz wide (.11n HT40) channels are listed separately from 20 MHz 2738c2ecf20Sopenharmony_ci * (legacy) channels. 2748c2ecf20Sopenharmony_ci * 2758c2ecf20Sopenharmony_ci * See struct il4965_eeprom_channel for format, and struct il4965_eeprom 2768c2ecf20Sopenharmony_ci * for locations in EEPROM. 2778c2ecf20Sopenharmony_ci * 2788c2ecf20Sopenharmony_ci * 2) Factory txpower calibration information is provided separately for 2798c2ecf20Sopenharmony_ci * sub-bands of contiguous channels. 2.4GHz has just one sub-band, 2808c2ecf20Sopenharmony_ci * but 5 GHz has several sub-bands. 2818c2ecf20Sopenharmony_ci * 2828c2ecf20Sopenharmony_ci * In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided. 2838c2ecf20Sopenharmony_ci * 2848c2ecf20Sopenharmony_ci * See struct il4965_eeprom_calib_info (and the tree of structures 2858c2ecf20Sopenharmony_ci * contained within it) for format, and struct il4965_eeprom for 2868c2ecf20Sopenharmony_ci * locations in EEPROM. 2878c2ecf20Sopenharmony_ci * 2888c2ecf20Sopenharmony_ci * "Initialization alive" notification (see struct il4965_init_alive_resp) 2898c2ecf20Sopenharmony_ci * consists of: 2908c2ecf20Sopenharmony_ci * 2918c2ecf20Sopenharmony_ci * 1) Temperature calculation parameters. 2928c2ecf20Sopenharmony_ci * 2938c2ecf20Sopenharmony_ci * 2) Power supply voltage measurement. 2948c2ecf20Sopenharmony_ci * 2958c2ecf20Sopenharmony_ci * 3) Tx gain compensation to balance 2 transmitters for MIMO use. 2968c2ecf20Sopenharmony_ci * 2978c2ecf20Sopenharmony_ci * Statistics notifications deliver: 2988c2ecf20Sopenharmony_ci * 2998c2ecf20Sopenharmony_ci * 1) Current values for temperature param R4. 3008c2ecf20Sopenharmony_ci */ 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci/** 3038c2ecf20Sopenharmony_ci * To calculate a txpower setting for a given desired target txpower, channel, 3048c2ecf20Sopenharmony_ci * modulation bit rate, and transmitter chain (4965 has 2 transmitters to 3058c2ecf20Sopenharmony_ci * support MIMO and transmit diversity), driver must do the following: 3068c2ecf20Sopenharmony_ci * 3078c2ecf20Sopenharmony_ci * 1) Compare desired txpower vs. (EEPROM) regulatory limit for this channel. 3088c2ecf20Sopenharmony_ci * Do not exceed regulatory limit; reduce target txpower if necessary. 3098c2ecf20Sopenharmony_ci * 3108c2ecf20Sopenharmony_ci * If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31), 3118c2ecf20Sopenharmony_ci * 2 transmitters will be used simultaneously; driver must reduce the 3128c2ecf20Sopenharmony_ci * regulatory limit by 3 dB (half-power) for each transmitter, so the 3138c2ecf20Sopenharmony_ci * combined total output of the 2 transmitters is within regulatory limits. 3148c2ecf20Sopenharmony_ci * 3158c2ecf20Sopenharmony_ci * 3168c2ecf20Sopenharmony_ci * 2) Compare target txpower vs. (EEPROM) saturation txpower *reduced by 3178c2ecf20Sopenharmony_ci * backoff for this bit rate*. Do not exceed (saturation - backoff[rate]); 3188c2ecf20Sopenharmony_ci * reduce target txpower if necessary. 3198c2ecf20Sopenharmony_ci * 3208c2ecf20Sopenharmony_ci * Backoff values below are in 1/2 dB units (equivalent to steps in 3218c2ecf20Sopenharmony_ci * txpower gain tables): 3228c2ecf20Sopenharmony_ci * 3238c2ecf20Sopenharmony_ci * OFDM 6 - 36 MBit: 10 steps (5 dB) 3248c2ecf20Sopenharmony_ci * OFDM 48 MBit: 15 steps (7.5 dB) 3258c2ecf20Sopenharmony_ci * OFDM 54 MBit: 17 steps (8.5 dB) 3268c2ecf20Sopenharmony_ci * OFDM 60 MBit: 20 steps (10 dB) 3278c2ecf20Sopenharmony_ci * CCK all rates: 10 steps (5 dB) 3288c2ecf20Sopenharmony_ci * 3298c2ecf20Sopenharmony_ci * Backoff values apply to saturation txpower on a per-transmitter basis; 3308c2ecf20Sopenharmony_ci * when using MIMO (2 transmitters), each transmitter uses the same 3318c2ecf20Sopenharmony_ci * saturation level provided in EEPROM, and the same backoff values; 3328c2ecf20Sopenharmony_ci * no reduction (such as with regulatory txpower limits) is required. 3338c2ecf20Sopenharmony_ci * 3348c2ecf20Sopenharmony_ci * Saturation and Backoff values apply equally to 20 Mhz (legacy) channel 3358c2ecf20Sopenharmony_ci * widths and 40 Mhz (.11n HT40) channel widths; there is no separate 3368c2ecf20Sopenharmony_ci * factory measurement for ht40 channels. 3378c2ecf20Sopenharmony_ci * 3388c2ecf20Sopenharmony_ci * The result of this step is the final target txpower. The rest of 3398c2ecf20Sopenharmony_ci * the steps figure out the proper settings for the device to achieve 3408c2ecf20Sopenharmony_ci * that target txpower. 3418c2ecf20Sopenharmony_ci * 3428c2ecf20Sopenharmony_ci * 3438c2ecf20Sopenharmony_ci * 3) Determine (EEPROM) calibration sub band for the target channel, by 3448c2ecf20Sopenharmony_ci * comparing against first and last channels in each sub band 3458c2ecf20Sopenharmony_ci * (see struct il4965_eeprom_calib_subband_info). 3468c2ecf20Sopenharmony_ci * 3478c2ecf20Sopenharmony_ci * 3488c2ecf20Sopenharmony_ci * 4) Linearly interpolate (EEPROM) factory calibration measurement sets, 3498c2ecf20Sopenharmony_ci * referencing the 2 factory-measured (sample) channels within the sub band. 3508c2ecf20Sopenharmony_ci * 3518c2ecf20Sopenharmony_ci * Interpolation is based on difference between target channel's frequency 3528c2ecf20Sopenharmony_ci * and the sample channels' frequencies. Since channel numbers are based 3538c2ecf20Sopenharmony_ci * on frequency (5 MHz between each channel number), this is equivalent 3548c2ecf20Sopenharmony_ci * to interpolating based on channel number differences. 3558c2ecf20Sopenharmony_ci * 3568c2ecf20Sopenharmony_ci * Note that the sample channels may or may not be the channels at the 3578c2ecf20Sopenharmony_ci * edges of the sub band. The target channel may be "outside" of the 3588c2ecf20Sopenharmony_ci * span of the sampled channels. 3598c2ecf20Sopenharmony_ci * 3608c2ecf20Sopenharmony_ci * Driver may choose the pair (for 2 Tx chains) of measurements (see 3618c2ecf20Sopenharmony_ci * struct il4965_eeprom_calib_ch_info) for which the actual measured 3628c2ecf20Sopenharmony_ci * txpower comes closest to the desired txpower. Usually, though, 3638c2ecf20Sopenharmony_ci * the middle set of measurements is closest to the regulatory limits, 3648c2ecf20Sopenharmony_ci * and is therefore a good choice for all txpower calculations (this 3658c2ecf20Sopenharmony_ci * assumes that high accuracy is needed for maximizing legal txpower, 3668c2ecf20Sopenharmony_ci * while lower txpower configurations do not need as much accuracy). 3678c2ecf20Sopenharmony_ci * 3688c2ecf20Sopenharmony_ci * Driver should interpolate both members of the chosen measurement pair, 3698c2ecf20Sopenharmony_ci * i.e. for both Tx chains (radio transmitters), unless the driver knows 3708c2ecf20Sopenharmony_ci * that only one of the chains will be used (e.g. only one tx antenna 3718c2ecf20Sopenharmony_ci * connected, but this should be unusual). The rate scaling algorithm 3728c2ecf20Sopenharmony_ci * switches antennas to find best performance, so both Tx chains will 3738c2ecf20Sopenharmony_ci * be used (although only one at a time) even for non-MIMO transmissions. 3748c2ecf20Sopenharmony_ci * 3758c2ecf20Sopenharmony_ci * Driver should interpolate factory values for temperature, gain table 3768c2ecf20Sopenharmony_ci * idx, and actual power. The power amplifier detector values are 3778c2ecf20Sopenharmony_ci * not used by the driver. 3788c2ecf20Sopenharmony_ci * 3798c2ecf20Sopenharmony_ci * Sanity check: If the target channel happens to be one of the sample 3808c2ecf20Sopenharmony_ci * channels, the results should agree with the sample channel's 3818c2ecf20Sopenharmony_ci * measurements! 3828c2ecf20Sopenharmony_ci * 3838c2ecf20Sopenharmony_ci * 3848c2ecf20Sopenharmony_ci * 5) Find difference between desired txpower and (interpolated) 3858c2ecf20Sopenharmony_ci * factory-measured txpower. Using (interpolated) factory gain table idx 3868c2ecf20Sopenharmony_ci * (shown elsewhere) as a starting point, adjust this idx lower to 3878c2ecf20Sopenharmony_ci * increase txpower, or higher to decrease txpower, until the target 3888c2ecf20Sopenharmony_ci * txpower is reached. Each step in the gain table is 1/2 dB. 3898c2ecf20Sopenharmony_ci * 3908c2ecf20Sopenharmony_ci * For example, if factory measured txpower is 16 dBm, and target txpower 3918c2ecf20Sopenharmony_ci * is 13 dBm, add 6 steps to the factory gain idx to reduce txpower 3928c2ecf20Sopenharmony_ci * by 3 dB. 3938c2ecf20Sopenharmony_ci * 3948c2ecf20Sopenharmony_ci * 3958c2ecf20Sopenharmony_ci * 6) Find difference between current device temperature and (interpolated) 3968c2ecf20Sopenharmony_ci * factory-measured temperature for sub-band. Factory values are in 3978c2ecf20Sopenharmony_ci * degrees Celsius. To calculate current temperature, see comments for 3988c2ecf20Sopenharmony_ci * "4965 temperature calculation". 3998c2ecf20Sopenharmony_ci * 4008c2ecf20Sopenharmony_ci * If current temperature is higher than factory temperature, driver must 4018c2ecf20Sopenharmony_ci * increase gain (lower gain table idx), and vice verse. 4028c2ecf20Sopenharmony_ci * 4038c2ecf20Sopenharmony_ci * Temperature affects gain differently for different channels: 4048c2ecf20Sopenharmony_ci * 4058c2ecf20Sopenharmony_ci * 2.4 GHz all channels: 3.5 degrees per half-dB step 4068c2ecf20Sopenharmony_ci * 5 GHz channels 34-43: 4.5 degrees per half-dB step 4078c2ecf20Sopenharmony_ci * 5 GHz channels >= 44: 4.0 degrees per half-dB step 4088c2ecf20Sopenharmony_ci * 4098c2ecf20Sopenharmony_ci * NOTE: Temperature can increase rapidly when transmitting, especially 4108c2ecf20Sopenharmony_ci * with heavy traffic at high txpowers. Driver should update 4118c2ecf20Sopenharmony_ci * temperature calculations often under these conditions to 4128c2ecf20Sopenharmony_ci * maintain strong txpower in the face of rising temperature. 4138c2ecf20Sopenharmony_ci * 4148c2ecf20Sopenharmony_ci * 4158c2ecf20Sopenharmony_ci * 7) Find difference between current power supply voltage indicator 4168c2ecf20Sopenharmony_ci * (from "initialize alive") and factory-measured power supply voltage 4178c2ecf20Sopenharmony_ci * indicator (EEPROM). 4188c2ecf20Sopenharmony_ci * 4198c2ecf20Sopenharmony_ci * If the current voltage is higher (indicator is lower) than factory 4208c2ecf20Sopenharmony_ci * voltage, gain should be reduced (gain table idx increased) by: 4218c2ecf20Sopenharmony_ci * 4228c2ecf20Sopenharmony_ci * (eeprom - current) / 7 4238c2ecf20Sopenharmony_ci * 4248c2ecf20Sopenharmony_ci * If the current voltage is lower (indicator is higher) than factory 4258c2ecf20Sopenharmony_ci * voltage, gain should be increased (gain table idx decreased) by: 4268c2ecf20Sopenharmony_ci * 4278c2ecf20Sopenharmony_ci * 2 * (current - eeprom) / 7 4288c2ecf20Sopenharmony_ci * 4298c2ecf20Sopenharmony_ci * If number of idx steps in either direction turns out to be > 2, 4308c2ecf20Sopenharmony_ci * something is wrong ... just use 0. 4318c2ecf20Sopenharmony_ci * 4328c2ecf20Sopenharmony_ci * NOTE: Voltage compensation is independent of band/channel. 4338c2ecf20Sopenharmony_ci * 4348c2ecf20Sopenharmony_ci * NOTE: "Initialize" uCode measures current voltage, which is assumed 4358c2ecf20Sopenharmony_ci * to be constant after this initial measurement. Voltage 4368c2ecf20Sopenharmony_ci * compensation for txpower (number of steps in gain table) 4378c2ecf20Sopenharmony_ci * may be calculated once and used until the next uCode bootload. 4388c2ecf20Sopenharmony_ci * 4398c2ecf20Sopenharmony_ci * 4408c2ecf20Sopenharmony_ci * 8) If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31), 4418c2ecf20Sopenharmony_ci * adjust txpower for each transmitter chain, so txpower is balanced 4428c2ecf20Sopenharmony_ci * between the two chains. There are 5 pairs of tx_atten[group][chain] 4438c2ecf20Sopenharmony_ci * values in "initialize alive", one pair for each of 5 channel ranges: 4448c2ecf20Sopenharmony_ci * 4458c2ecf20Sopenharmony_ci * Group 0: 5 GHz channel 34-43 4468c2ecf20Sopenharmony_ci * Group 1: 5 GHz channel 44-70 4478c2ecf20Sopenharmony_ci * Group 2: 5 GHz channel 71-124 4488c2ecf20Sopenharmony_ci * Group 3: 5 GHz channel 125-200 4498c2ecf20Sopenharmony_ci * Group 4: 2.4 GHz all channels 4508c2ecf20Sopenharmony_ci * 4518c2ecf20Sopenharmony_ci * Add the tx_atten[group][chain] value to the idx for the target chain. 4528c2ecf20Sopenharmony_ci * The values are signed, but are in pairs of 0 and a non-negative number, 4538c2ecf20Sopenharmony_ci * so as to reduce gain (if necessary) of the "hotter" channel. This 4548c2ecf20Sopenharmony_ci * avoids any need to double-check for regulatory compliance after 4558c2ecf20Sopenharmony_ci * this step. 4568c2ecf20Sopenharmony_ci * 4578c2ecf20Sopenharmony_ci * 4588c2ecf20Sopenharmony_ci * 9) If setting up for a CCK rate, lower the gain by adding a CCK compensation 4598c2ecf20Sopenharmony_ci * value to the idx: 4608c2ecf20Sopenharmony_ci * 4618c2ecf20Sopenharmony_ci * Hardware rev B: 9 steps (4.5 dB) 4628c2ecf20Sopenharmony_ci * Hardware rev C: 5 steps (2.5 dB) 4638c2ecf20Sopenharmony_ci * 4648c2ecf20Sopenharmony_ci * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, 4658c2ecf20Sopenharmony_ci * bits [3:2], 1 = B, 2 = C. 4668c2ecf20Sopenharmony_ci * 4678c2ecf20Sopenharmony_ci * NOTE: This compensation is in addition to any saturation backoff that 4688c2ecf20Sopenharmony_ci * might have been applied in an earlier step. 4698c2ecf20Sopenharmony_ci * 4708c2ecf20Sopenharmony_ci * 4718c2ecf20Sopenharmony_ci * 10) Select the gain table, based on band (2.4 vs 5 GHz). 4728c2ecf20Sopenharmony_ci * 4738c2ecf20Sopenharmony_ci * Limit the adjusted idx to stay within the table! 4748c2ecf20Sopenharmony_ci * 4758c2ecf20Sopenharmony_ci * 4768c2ecf20Sopenharmony_ci * 11) Read gain table entries for DSP and radio gain, place into appropriate 4778c2ecf20Sopenharmony_ci * location(s) in command (struct il4965_txpowertable_cmd). 4788c2ecf20Sopenharmony_ci */ 4798c2ecf20Sopenharmony_ci 4808c2ecf20Sopenharmony_ci/** 4818c2ecf20Sopenharmony_ci * When MIMO is used (2 transmitters operating simultaneously), driver should 4828c2ecf20Sopenharmony_ci * limit each transmitter to deliver a max of 3 dB below the regulatory limit 4838c2ecf20Sopenharmony_ci * for the device. That is, use half power for each transmitter, so total 4848c2ecf20Sopenharmony_ci * txpower is within regulatory limits. 4858c2ecf20Sopenharmony_ci * 4868c2ecf20Sopenharmony_ci * The value "6" represents number of steps in gain table to reduce power 3 dB. 4878c2ecf20Sopenharmony_ci * Each step is 1/2 dB. 4888c2ecf20Sopenharmony_ci */ 4898c2ecf20Sopenharmony_ci#define IL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6) 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci/** 4928c2ecf20Sopenharmony_ci * CCK gain compensation. 4938c2ecf20Sopenharmony_ci * 4948c2ecf20Sopenharmony_ci * When calculating txpowers for CCK, after making sure that the target power 4958c2ecf20Sopenharmony_ci * is within regulatory and saturation limits, driver must additionally 4968c2ecf20Sopenharmony_ci * back off gain by adding these values to the gain table idx. 4978c2ecf20Sopenharmony_ci * 4988c2ecf20Sopenharmony_ci * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, 4998c2ecf20Sopenharmony_ci * bits [3:2], 1 = B, 2 = C. 5008c2ecf20Sopenharmony_ci */ 5018c2ecf20Sopenharmony_ci#define IL_TX_POWER_CCK_COMPENSATION_B_STEP (9) 5028c2ecf20Sopenharmony_ci#define IL_TX_POWER_CCK_COMPENSATION_C_STEP (5) 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_ci/* 5058c2ecf20Sopenharmony_ci * 4965 power supply voltage compensation for txpower 5068c2ecf20Sopenharmony_ci */ 5078c2ecf20Sopenharmony_ci#define TX_POWER_IL_VOLTAGE_CODES_PER_03V (7) 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_ci/** 5108c2ecf20Sopenharmony_ci * Gain tables. 5118c2ecf20Sopenharmony_ci * 5128c2ecf20Sopenharmony_ci * The following tables contain pair of values for setting txpower, i.e. 5138c2ecf20Sopenharmony_ci * gain settings for the output of the device's digital signal processor (DSP), 5148c2ecf20Sopenharmony_ci * and for the analog gain structure of the transmitter. 5158c2ecf20Sopenharmony_ci * 5168c2ecf20Sopenharmony_ci * Each entry in the gain tables represents a step of 1/2 dB. Note that these 5178c2ecf20Sopenharmony_ci * are *relative* steps, not indications of absolute output power. Output 5188c2ecf20Sopenharmony_ci * power varies with temperature, voltage, and channel frequency, and also 5198c2ecf20Sopenharmony_ci * requires consideration of average power (to satisfy regulatory constraints), 5208c2ecf20Sopenharmony_ci * and peak power (to avoid distortion of the output signal). 5218c2ecf20Sopenharmony_ci * 5228c2ecf20Sopenharmony_ci * Each entry contains two values: 5238c2ecf20Sopenharmony_ci * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained 5248c2ecf20Sopenharmony_ci * linear value that multiplies the output of the digital signal processor, 5258c2ecf20Sopenharmony_ci * before being sent to the analog radio. 5268c2ecf20Sopenharmony_ci * 2) Radio gain. This sets the analog gain of the radio Tx path. 5278c2ecf20Sopenharmony_ci * It is a coarser setting, and behaves in a logarithmic (dB) fashion. 5288c2ecf20Sopenharmony_ci * 5298c2ecf20Sopenharmony_ci * EEPROM contains factory calibration data for txpower. This maps actual 5308c2ecf20Sopenharmony_ci * measured txpower levels to gain settings in the "well known" tables 5318c2ecf20Sopenharmony_ci * below ("well-known" means here that both factory calibration *and* the 5328c2ecf20Sopenharmony_ci * driver work with the same table). 5338c2ecf20Sopenharmony_ci * 5348c2ecf20Sopenharmony_ci * There are separate tables for 2.4 GHz and 5 GHz bands. The 5 GHz table 5358c2ecf20Sopenharmony_ci * has an extension (into negative idxes), in case the driver needs to 5368c2ecf20Sopenharmony_ci * boost power setting for high device temperatures (higher than would be 5378c2ecf20Sopenharmony_ci * present during factory calibration). A 5 Ghz EEPROM idx of "40" 5388c2ecf20Sopenharmony_ci * corresponds to the 49th entry in the table used by the driver. 5398c2ecf20Sopenharmony_ci */ 5408c2ecf20Sopenharmony_ci#define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */ 5418c2ecf20Sopenharmony_ci#define MIN_TX_GAIN_IDX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_ci/** 5448c2ecf20Sopenharmony_ci * 2.4 GHz gain table 5458c2ecf20Sopenharmony_ci * 5468c2ecf20Sopenharmony_ci * Index Dsp gain Radio gain 5478c2ecf20Sopenharmony_ci * 0 110 0x3f (highest gain) 5488c2ecf20Sopenharmony_ci * 1 104 0x3f 5498c2ecf20Sopenharmony_ci * 2 98 0x3f 5508c2ecf20Sopenharmony_ci * 3 110 0x3e 5518c2ecf20Sopenharmony_ci * 4 104 0x3e 5528c2ecf20Sopenharmony_ci * 5 98 0x3e 5538c2ecf20Sopenharmony_ci * 6 110 0x3d 5548c2ecf20Sopenharmony_ci * 7 104 0x3d 5558c2ecf20Sopenharmony_ci * 8 98 0x3d 5568c2ecf20Sopenharmony_ci * 9 110 0x3c 5578c2ecf20Sopenharmony_ci * 10 104 0x3c 5588c2ecf20Sopenharmony_ci * 11 98 0x3c 5598c2ecf20Sopenharmony_ci * 12 110 0x3b 5608c2ecf20Sopenharmony_ci * 13 104 0x3b 5618c2ecf20Sopenharmony_ci * 14 98 0x3b 5628c2ecf20Sopenharmony_ci * 15 110 0x3a 5638c2ecf20Sopenharmony_ci * 16 104 0x3a 5648c2ecf20Sopenharmony_ci * 17 98 0x3a 5658c2ecf20Sopenharmony_ci * 18 110 0x39 5668c2ecf20Sopenharmony_ci * 19 104 0x39 5678c2ecf20Sopenharmony_ci * 20 98 0x39 5688c2ecf20Sopenharmony_ci * 21 110 0x38 5698c2ecf20Sopenharmony_ci * 22 104 0x38 5708c2ecf20Sopenharmony_ci * 23 98 0x38 5718c2ecf20Sopenharmony_ci * 24 110 0x37 5728c2ecf20Sopenharmony_ci * 25 104 0x37 5738c2ecf20Sopenharmony_ci * 26 98 0x37 5748c2ecf20Sopenharmony_ci * 27 110 0x36 5758c2ecf20Sopenharmony_ci * 28 104 0x36 5768c2ecf20Sopenharmony_ci * 29 98 0x36 5778c2ecf20Sopenharmony_ci * 30 110 0x35 5788c2ecf20Sopenharmony_ci * 31 104 0x35 5798c2ecf20Sopenharmony_ci * 32 98 0x35 5808c2ecf20Sopenharmony_ci * 33 110 0x34 5818c2ecf20Sopenharmony_ci * 34 104 0x34 5828c2ecf20Sopenharmony_ci * 35 98 0x34 5838c2ecf20Sopenharmony_ci * 36 110 0x33 5848c2ecf20Sopenharmony_ci * 37 104 0x33 5858c2ecf20Sopenharmony_ci * 38 98 0x33 5868c2ecf20Sopenharmony_ci * 39 110 0x32 5878c2ecf20Sopenharmony_ci * 40 104 0x32 5888c2ecf20Sopenharmony_ci * 41 98 0x32 5898c2ecf20Sopenharmony_ci * 42 110 0x31 5908c2ecf20Sopenharmony_ci * 43 104 0x31 5918c2ecf20Sopenharmony_ci * 44 98 0x31 5928c2ecf20Sopenharmony_ci * 45 110 0x30 5938c2ecf20Sopenharmony_ci * 46 104 0x30 5948c2ecf20Sopenharmony_ci * 47 98 0x30 5958c2ecf20Sopenharmony_ci * 48 110 0x6 5968c2ecf20Sopenharmony_ci * 49 104 0x6 5978c2ecf20Sopenharmony_ci * 50 98 0x6 5988c2ecf20Sopenharmony_ci * 51 110 0x5 5998c2ecf20Sopenharmony_ci * 52 104 0x5 6008c2ecf20Sopenharmony_ci * 53 98 0x5 6018c2ecf20Sopenharmony_ci * 54 110 0x4 6028c2ecf20Sopenharmony_ci * 55 104 0x4 6038c2ecf20Sopenharmony_ci * 56 98 0x4 6048c2ecf20Sopenharmony_ci * 57 110 0x3 6058c2ecf20Sopenharmony_ci * 58 104 0x3 6068c2ecf20Sopenharmony_ci * 59 98 0x3 6078c2ecf20Sopenharmony_ci * 60 110 0x2 6088c2ecf20Sopenharmony_ci * 61 104 0x2 6098c2ecf20Sopenharmony_ci * 62 98 0x2 6108c2ecf20Sopenharmony_ci * 63 110 0x1 6118c2ecf20Sopenharmony_ci * 64 104 0x1 6128c2ecf20Sopenharmony_ci * 65 98 0x1 6138c2ecf20Sopenharmony_ci * 66 110 0x0 6148c2ecf20Sopenharmony_ci * 67 104 0x0 6158c2ecf20Sopenharmony_ci * 68 98 0x0 6168c2ecf20Sopenharmony_ci * 69 97 0 6178c2ecf20Sopenharmony_ci * 70 96 0 6188c2ecf20Sopenharmony_ci * 71 95 0 6198c2ecf20Sopenharmony_ci * 72 94 0 6208c2ecf20Sopenharmony_ci * 73 93 0 6218c2ecf20Sopenharmony_ci * 74 92 0 6228c2ecf20Sopenharmony_ci * 75 91 0 6238c2ecf20Sopenharmony_ci * 76 90 0 6248c2ecf20Sopenharmony_ci * 77 89 0 6258c2ecf20Sopenharmony_ci * 78 88 0 6268c2ecf20Sopenharmony_ci * 79 87 0 6278c2ecf20Sopenharmony_ci * 80 86 0 6288c2ecf20Sopenharmony_ci * 81 85 0 6298c2ecf20Sopenharmony_ci * 82 84 0 6308c2ecf20Sopenharmony_ci * 83 83 0 6318c2ecf20Sopenharmony_ci * 84 82 0 6328c2ecf20Sopenharmony_ci * 85 81 0 6338c2ecf20Sopenharmony_ci * 86 80 0 6348c2ecf20Sopenharmony_ci * 87 79 0 6358c2ecf20Sopenharmony_ci * 88 78 0 6368c2ecf20Sopenharmony_ci * 89 77 0 6378c2ecf20Sopenharmony_ci * 90 76 0 6388c2ecf20Sopenharmony_ci * 91 75 0 6398c2ecf20Sopenharmony_ci * 92 74 0 6408c2ecf20Sopenharmony_ci * 93 73 0 6418c2ecf20Sopenharmony_ci * 94 72 0 6428c2ecf20Sopenharmony_ci * 95 71 0 6438c2ecf20Sopenharmony_ci * 96 70 0 6448c2ecf20Sopenharmony_ci * 97 69 0 6458c2ecf20Sopenharmony_ci * 98 68 0 6468c2ecf20Sopenharmony_ci */ 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_ci/** 6498c2ecf20Sopenharmony_ci * 5 GHz gain table 6508c2ecf20Sopenharmony_ci * 6518c2ecf20Sopenharmony_ci * Index Dsp gain Radio gain 6528c2ecf20Sopenharmony_ci * -9 123 0x3F (highest gain) 6538c2ecf20Sopenharmony_ci * -8 117 0x3F 6548c2ecf20Sopenharmony_ci * -7 110 0x3F 6558c2ecf20Sopenharmony_ci * -6 104 0x3F 6568c2ecf20Sopenharmony_ci * -5 98 0x3F 6578c2ecf20Sopenharmony_ci * -4 110 0x3E 6588c2ecf20Sopenharmony_ci * -3 104 0x3E 6598c2ecf20Sopenharmony_ci * -2 98 0x3E 6608c2ecf20Sopenharmony_ci * -1 110 0x3D 6618c2ecf20Sopenharmony_ci * 0 104 0x3D 6628c2ecf20Sopenharmony_ci * 1 98 0x3D 6638c2ecf20Sopenharmony_ci * 2 110 0x3C 6648c2ecf20Sopenharmony_ci * 3 104 0x3C 6658c2ecf20Sopenharmony_ci * 4 98 0x3C 6668c2ecf20Sopenharmony_ci * 5 110 0x3B 6678c2ecf20Sopenharmony_ci * 6 104 0x3B 6688c2ecf20Sopenharmony_ci * 7 98 0x3B 6698c2ecf20Sopenharmony_ci * 8 110 0x3A 6708c2ecf20Sopenharmony_ci * 9 104 0x3A 6718c2ecf20Sopenharmony_ci * 10 98 0x3A 6728c2ecf20Sopenharmony_ci * 11 110 0x39 6738c2ecf20Sopenharmony_ci * 12 104 0x39 6748c2ecf20Sopenharmony_ci * 13 98 0x39 6758c2ecf20Sopenharmony_ci * 14 110 0x38 6768c2ecf20Sopenharmony_ci * 15 104 0x38 6778c2ecf20Sopenharmony_ci * 16 98 0x38 6788c2ecf20Sopenharmony_ci * 17 110 0x37 6798c2ecf20Sopenharmony_ci * 18 104 0x37 6808c2ecf20Sopenharmony_ci * 19 98 0x37 6818c2ecf20Sopenharmony_ci * 20 110 0x36 6828c2ecf20Sopenharmony_ci * 21 104 0x36 6838c2ecf20Sopenharmony_ci * 22 98 0x36 6848c2ecf20Sopenharmony_ci * 23 110 0x35 6858c2ecf20Sopenharmony_ci * 24 104 0x35 6868c2ecf20Sopenharmony_ci * 25 98 0x35 6878c2ecf20Sopenharmony_ci * 26 110 0x34 6888c2ecf20Sopenharmony_ci * 27 104 0x34 6898c2ecf20Sopenharmony_ci * 28 98 0x34 6908c2ecf20Sopenharmony_ci * 29 110 0x33 6918c2ecf20Sopenharmony_ci * 30 104 0x33 6928c2ecf20Sopenharmony_ci * 31 98 0x33 6938c2ecf20Sopenharmony_ci * 32 110 0x32 6948c2ecf20Sopenharmony_ci * 33 104 0x32 6958c2ecf20Sopenharmony_ci * 34 98 0x32 6968c2ecf20Sopenharmony_ci * 35 110 0x31 6978c2ecf20Sopenharmony_ci * 36 104 0x31 6988c2ecf20Sopenharmony_ci * 37 98 0x31 6998c2ecf20Sopenharmony_ci * 38 110 0x30 7008c2ecf20Sopenharmony_ci * 39 104 0x30 7018c2ecf20Sopenharmony_ci * 40 98 0x30 7028c2ecf20Sopenharmony_ci * 41 110 0x25 7038c2ecf20Sopenharmony_ci * 42 104 0x25 7048c2ecf20Sopenharmony_ci * 43 98 0x25 7058c2ecf20Sopenharmony_ci * 44 110 0x24 7068c2ecf20Sopenharmony_ci * 45 104 0x24 7078c2ecf20Sopenharmony_ci * 46 98 0x24 7088c2ecf20Sopenharmony_ci * 47 110 0x23 7098c2ecf20Sopenharmony_ci * 48 104 0x23 7108c2ecf20Sopenharmony_ci * 49 98 0x23 7118c2ecf20Sopenharmony_ci * 50 110 0x22 7128c2ecf20Sopenharmony_ci * 51 104 0x18 7138c2ecf20Sopenharmony_ci * 52 98 0x18 7148c2ecf20Sopenharmony_ci * 53 110 0x17 7158c2ecf20Sopenharmony_ci * 54 104 0x17 7168c2ecf20Sopenharmony_ci * 55 98 0x17 7178c2ecf20Sopenharmony_ci * 56 110 0x16 7188c2ecf20Sopenharmony_ci * 57 104 0x16 7198c2ecf20Sopenharmony_ci * 58 98 0x16 7208c2ecf20Sopenharmony_ci * 59 110 0x15 7218c2ecf20Sopenharmony_ci * 60 104 0x15 7228c2ecf20Sopenharmony_ci * 61 98 0x15 7238c2ecf20Sopenharmony_ci * 62 110 0x14 7248c2ecf20Sopenharmony_ci * 63 104 0x14 7258c2ecf20Sopenharmony_ci * 64 98 0x14 7268c2ecf20Sopenharmony_ci * 65 110 0x13 7278c2ecf20Sopenharmony_ci * 66 104 0x13 7288c2ecf20Sopenharmony_ci * 67 98 0x13 7298c2ecf20Sopenharmony_ci * 68 110 0x12 7308c2ecf20Sopenharmony_ci * 69 104 0x08 7318c2ecf20Sopenharmony_ci * 70 98 0x08 7328c2ecf20Sopenharmony_ci * 71 110 0x07 7338c2ecf20Sopenharmony_ci * 72 104 0x07 7348c2ecf20Sopenharmony_ci * 73 98 0x07 7358c2ecf20Sopenharmony_ci * 74 110 0x06 7368c2ecf20Sopenharmony_ci * 75 104 0x06 7378c2ecf20Sopenharmony_ci * 76 98 0x06 7388c2ecf20Sopenharmony_ci * 77 110 0x05 7398c2ecf20Sopenharmony_ci * 78 104 0x05 7408c2ecf20Sopenharmony_ci * 79 98 0x05 7418c2ecf20Sopenharmony_ci * 80 110 0x04 7428c2ecf20Sopenharmony_ci * 81 104 0x04 7438c2ecf20Sopenharmony_ci * 82 98 0x04 7448c2ecf20Sopenharmony_ci * 83 110 0x03 7458c2ecf20Sopenharmony_ci * 84 104 0x03 7468c2ecf20Sopenharmony_ci * 85 98 0x03 7478c2ecf20Sopenharmony_ci * 86 110 0x02 7488c2ecf20Sopenharmony_ci * 87 104 0x02 7498c2ecf20Sopenharmony_ci * 88 98 0x02 7508c2ecf20Sopenharmony_ci * 89 110 0x01 7518c2ecf20Sopenharmony_ci * 90 104 0x01 7528c2ecf20Sopenharmony_ci * 91 98 0x01 7538c2ecf20Sopenharmony_ci * 92 110 0x00 7548c2ecf20Sopenharmony_ci * 93 104 0x00 7558c2ecf20Sopenharmony_ci * 94 98 0x00 7568c2ecf20Sopenharmony_ci * 95 93 0x00 7578c2ecf20Sopenharmony_ci * 96 88 0x00 7588c2ecf20Sopenharmony_ci * 97 83 0x00 7598c2ecf20Sopenharmony_ci * 98 78 0x00 7608c2ecf20Sopenharmony_ci */ 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_ci/** 7638c2ecf20Sopenharmony_ci * Sanity checks and default values for EEPROM regulatory levels. 7648c2ecf20Sopenharmony_ci * If EEPROM values fall outside MIN/MAX range, use default values. 7658c2ecf20Sopenharmony_ci * 7668c2ecf20Sopenharmony_ci * Regulatory limits refer to the maximum average txpower allowed by 7678c2ecf20Sopenharmony_ci * regulatory agencies in the geographies in which the device is meant 7688c2ecf20Sopenharmony_ci * to be operated. These limits are SKU-specific (i.e. geography-specific), 7698c2ecf20Sopenharmony_ci * and channel-specific; each channel has an individual regulatory limit 7708c2ecf20Sopenharmony_ci * listed in the EEPROM. 7718c2ecf20Sopenharmony_ci * 7728c2ecf20Sopenharmony_ci * Units are in half-dBm (i.e. "34" means 17 dBm). 7738c2ecf20Sopenharmony_ci */ 7748c2ecf20Sopenharmony_ci#define IL_TX_POWER_DEFAULT_REGULATORY_24 (34) 7758c2ecf20Sopenharmony_ci#define IL_TX_POWER_DEFAULT_REGULATORY_52 (34) 7768c2ecf20Sopenharmony_ci#define IL_TX_POWER_REGULATORY_MIN (0) 7778c2ecf20Sopenharmony_ci#define IL_TX_POWER_REGULATORY_MAX (34) 7788c2ecf20Sopenharmony_ci 7798c2ecf20Sopenharmony_ci/** 7808c2ecf20Sopenharmony_ci * Sanity checks and default values for EEPROM saturation levels. 7818c2ecf20Sopenharmony_ci * If EEPROM values fall outside MIN/MAX range, use default values. 7828c2ecf20Sopenharmony_ci * 7838c2ecf20Sopenharmony_ci * Saturation is the highest level that the output power amplifier can produce 7848c2ecf20Sopenharmony_ci * without significant clipping distortion. This is a "peak" power level. 7858c2ecf20Sopenharmony_ci * Different types of modulation (i.e. various "rates", and OFDM vs. CCK) 7868c2ecf20Sopenharmony_ci * require differing amounts of backoff, relative to their average power output, 7878c2ecf20Sopenharmony_ci * in order to avoid clipping distortion. 7888c2ecf20Sopenharmony_ci * 7898c2ecf20Sopenharmony_ci * Driver must make sure that it is violating neither the saturation limit, 7908c2ecf20Sopenharmony_ci * nor the regulatory limit, when calculating Tx power settings for various 7918c2ecf20Sopenharmony_ci * rates. 7928c2ecf20Sopenharmony_ci * 7938c2ecf20Sopenharmony_ci * Units are in half-dBm (i.e. "38" means 19 dBm). 7948c2ecf20Sopenharmony_ci */ 7958c2ecf20Sopenharmony_ci#define IL_TX_POWER_DEFAULT_SATURATION_24 (38) 7968c2ecf20Sopenharmony_ci#define IL_TX_POWER_DEFAULT_SATURATION_52 (38) 7978c2ecf20Sopenharmony_ci#define IL_TX_POWER_SATURATION_MIN (20) 7988c2ecf20Sopenharmony_ci#define IL_TX_POWER_SATURATION_MAX (50) 7998c2ecf20Sopenharmony_ci 8008c2ecf20Sopenharmony_ci/** 8018c2ecf20Sopenharmony_ci * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance) 8028c2ecf20Sopenharmony_ci * and thermal Txpower calibration. 8038c2ecf20Sopenharmony_ci * 8048c2ecf20Sopenharmony_ci * When calculating txpower, driver must compensate for current device 8058c2ecf20Sopenharmony_ci * temperature; higher temperature requires higher gain. Driver must calculate 8068c2ecf20Sopenharmony_ci * current temperature (see "4965 temperature calculation"), then compare vs. 8078c2ecf20Sopenharmony_ci * factory calibration temperature in EEPROM; if current temperature is higher 8088c2ecf20Sopenharmony_ci * than factory temperature, driver must *increase* gain by proportions shown 8098c2ecf20Sopenharmony_ci * in table below. If current temperature is lower than factory, driver must 8108c2ecf20Sopenharmony_ci * *decrease* gain. 8118c2ecf20Sopenharmony_ci * 8128c2ecf20Sopenharmony_ci * Different frequency ranges require different compensation, as shown below. 8138c2ecf20Sopenharmony_ci */ 8148c2ecf20Sopenharmony_ci/* Group 0, 5.2 GHz ch 34-43: 4.5 degrees per 1/2 dB. */ 8158c2ecf20Sopenharmony_ci#define CALIB_IL_TX_ATTEN_GR1_FCH 34 8168c2ecf20Sopenharmony_ci#define CALIB_IL_TX_ATTEN_GR1_LCH 43 8178c2ecf20Sopenharmony_ci 8188c2ecf20Sopenharmony_ci/* Group 1, 5.3 GHz ch 44-70: 4.0 degrees per 1/2 dB. */ 8198c2ecf20Sopenharmony_ci#define CALIB_IL_TX_ATTEN_GR2_FCH 44 8208c2ecf20Sopenharmony_ci#define CALIB_IL_TX_ATTEN_GR2_LCH 70 8218c2ecf20Sopenharmony_ci 8228c2ecf20Sopenharmony_ci/* Group 2, 5.5 GHz ch 71-124: 4.0 degrees per 1/2 dB. */ 8238c2ecf20Sopenharmony_ci#define CALIB_IL_TX_ATTEN_GR3_FCH 71 8248c2ecf20Sopenharmony_ci#define CALIB_IL_TX_ATTEN_GR3_LCH 124 8258c2ecf20Sopenharmony_ci 8268c2ecf20Sopenharmony_ci/* Group 3, 5.7 GHz ch 125-200: 4.0 degrees per 1/2 dB. */ 8278c2ecf20Sopenharmony_ci#define CALIB_IL_TX_ATTEN_GR4_FCH 125 8288c2ecf20Sopenharmony_ci#define CALIB_IL_TX_ATTEN_GR4_LCH 200 8298c2ecf20Sopenharmony_ci 8308c2ecf20Sopenharmony_ci/* Group 4, 2.4 GHz all channels: 3.5 degrees per 1/2 dB. */ 8318c2ecf20Sopenharmony_ci#define CALIB_IL_TX_ATTEN_GR5_FCH 1 8328c2ecf20Sopenharmony_ci#define CALIB_IL_TX_ATTEN_GR5_LCH 20 8338c2ecf20Sopenharmony_ci 8348c2ecf20Sopenharmony_cienum { 8358c2ecf20Sopenharmony_ci CALIB_CH_GROUP_1 = 0, 8368c2ecf20Sopenharmony_ci CALIB_CH_GROUP_2 = 1, 8378c2ecf20Sopenharmony_ci CALIB_CH_GROUP_3 = 2, 8388c2ecf20Sopenharmony_ci CALIB_CH_GROUP_4 = 3, 8398c2ecf20Sopenharmony_ci CALIB_CH_GROUP_5 = 4, 8408c2ecf20Sopenharmony_ci CALIB_CH_GROUP_MAX 8418c2ecf20Sopenharmony_ci}; 8428c2ecf20Sopenharmony_ci 8438c2ecf20Sopenharmony_ci/********************* END TXPOWER *****************************************/ 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_ci/** 8468c2ecf20Sopenharmony_ci * Tx/Rx Queues 8478c2ecf20Sopenharmony_ci * 8488c2ecf20Sopenharmony_ci * Most communication between driver and 4965 is via queues of data buffers. 8498c2ecf20Sopenharmony_ci * For example, all commands that the driver issues to device's embedded 8508c2ecf20Sopenharmony_ci * controller (uCode) are via the command queue (one of the Tx queues). All 8518c2ecf20Sopenharmony_ci * uCode command responses/replies/notifications, including Rx frames, are 8528c2ecf20Sopenharmony_ci * conveyed from uCode to driver via the Rx queue. 8538c2ecf20Sopenharmony_ci * 8548c2ecf20Sopenharmony_ci * Most support for these queues, including handshake support, resides in 8558c2ecf20Sopenharmony_ci * structures in host DRAM, shared between the driver and the device. When 8568c2ecf20Sopenharmony_ci * allocating this memory, the driver must make sure that data written by 8578c2ecf20Sopenharmony_ci * the host CPU updates DRAM immediately (and does not get "stuck" in CPU's 8588c2ecf20Sopenharmony_ci * cache memory), so DRAM and cache are consistent, and the device can 8598c2ecf20Sopenharmony_ci * immediately see changes made by the driver. 8608c2ecf20Sopenharmony_ci * 8618c2ecf20Sopenharmony_ci * 4965 supports up to 16 DRAM-based Tx queues, and services these queues via 8628c2ecf20Sopenharmony_ci * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array 8638c2ecf20Sopenharmony_ci * in DRAM containing 256 Transmit Frame Descriptors (TFDs). 8648c2ecf20Sopenharmony_ci */ 8658c2ecf20Sopenharmony_ci#define IL49_NUM_FIFOS 7 8668c2ecf20Sopenharmony_ci#define IL49_CMD_FIFO_NUM 4 8678c2ecf20Sopenharmony_ci#define IL49_NUM_QUEUES 16 8688c2ecf20Sopenharmony_ci#define IL49_NUM_AMPDU_QUEUES 8 8698c2ecf20Sopenharmony_ci 8708c2ecf20Sopenharmony_ci/** 8718c2ecf20Sopenharmony_ci * struct il4965_schedq_bc_tbl 8728c2ecf20Sopenharmony_ci * 8738c2ecf20Sopenharmony_ci * Byte Count table 8748c2ecf20Sopenharmony_ci * 8758c2ecf20Sopenharmony_ci * Each Tx queue uses a byte-count table containing 320 entries: 8768c2ecf20Sopenharmony_ci * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that 8778c2ecf20Sopenharmony_ci * duplicate the first 64 entries (to avoid wrap-around within a Tx win; 8788c2ecf20Sopenharmony_ci * max Tx win is 64 TFDs). 8798c2ecf20Sopenharmony_ci * 8808c2ecf20Sopenharmony_ci * When driver sets up a new TFD, it must also enter the total byte count 8818c2ecf20Sopenharmony_ci * of the frame to be transmitted into the corresponding entry in the byte 8828c2ecf20Sopenharmony_ci * count table for the chosen Tx queue. If the TFD idx is 0-63, the driver 8838c2ecf20Sopenharmony_ci * must duplicate the byte count entry in corresponding idx 256-319. 8848c2ecf20Sopenharmony_ci * 8858c2ecf20Sopenharmony_ci * padding puts each byte count table on a 1024-byte boundary; 8868c2ecf20Sopenharmony_ci * 4965 assumes tables are separated by 1024 bytes. 8878c2ecf20Sopenharmony_ci */ 8888c2ecf20Sopenharmony_cistruct il4965_scd_bc_tbl { 8898c2ecf20Sopenharmony_ci __le16 tfd_offset[TFD_QUEUE_BC_SIZE]; 8908c2ecf20Sopenharmony_ci u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)]; 8918c2ecf20Sopenharmony_ci} __packed; 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_ci#define IL4965_RTC_INST_LOWER_BOUND (0x000000) 8948c2ecf20Sopenharmony_ci 8958c2ecf20Sopenharmony_ci/* RSSI to dBm */ 8968c2ecf20Sopenharmony_ci#define IL4965_RSSI_OFFSET 44 8978c2ecf20Sopenharmony_ci 8988c2ecf20Sopenharmony_ci/* PCI registers */ 8998c2ecf20Sopenharmony_ci#define PCI_CFG_RETRY_TIMEOUT 0x041 9008c2ecf20Sopenharmony_ci 9018c2ecf20Sopenharmony_ci#define IL4965_DEFAULT_TX_RETRY 15 9028c2ecf20Sopenharmony_ci 9038c2ecf20Sopenharmony_ci/* EEPROM */ 9048c2ecf20Sopenharmony_ci#define IL4965_FIRST_AMPDU_QUEUE 10 9058c2ecf20Sopenharmony_ci 9068c2ecf20Sopenharmony_ci/* Calibration */ 9078c2ecf20Sopenharmony_civoid il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp); 9088c2ecf20Sopenharmony_civoid il4965_sensitivity_calibration(struct il_priv *il, void *resp); 9098c2ecf20Sopenharmony_civoid il4965_init_sensitivity(struct il_priv *il); 9108c2ecf20Sopenharmony_civoid il4965_reset_run_time_calib(struct il_priv *il); 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_ci/* Debug */ 9138c2ecf20Sopenharmony_ci#ifdef CONFIG_IWLEGACY_DEBUGFS 9148c2ecf20Sopenharmony_ciextern const struct il_debugfs_ops il4965_debugfs_ops; 9158c2ecf20Sopenharmony_ci#endif 9168c2ecf20Sopenharmony_ci 9178c2ecf20Sopenharmony_ci/****************************/ 9188c2ecf20Sopenharmony_ci/* Flow Handler Definitions */ 9198c2ecf20Sopenharmony_ci/****************************/ 9208c2ecf20Sopenharmony_ci 9218c2ecf20Sopenharmony_ci/** 9228c2ecf20Sopenharmony_ci * This I/O area is directly read/writable by driver (e.g. Linux uses writel()) 9238c2ecf20Sopenharmony_ci * Addresses are offsets from device's PCI hardware base address. 9248c2ecf20Sopenharmony_ci */ 9258c2ecf20Sopenharmony_ci#define FH49_MEM_LOWER_BOUND (0x1000) 9268c2ecf20Sopenharmony_ci#define FH49_MEM_UPPER_BOUND (0x2000) 9278c2ecf20Sopenharmony_ci 9288c2ecf20Sopenharmony_ci/** 9298c2ecf20Sopenharmony_ci * Keep-Warm (KW) buffer base address. 9308c2ecf20Sopenharmony_ci * 9318c2ecf20Sopenharmony_ci * Driver must allocate a 4KByte buffer that is used by 4965 for keeping the 9328c2ecf20Sopenharmony_ci * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency 9338c2ecf20Sopenharmony_ci * DRAM access when 4965 is Txing or Rxing. The dummy accesses prevent host 9348c2ecf20Sopenharmony_ci * from going into a power-savings mode that would cause higher DRAM latency, 9358c2ecf20Sopenharmony_ci * and possible data over/under-runs, before all Tx/Rx is complete. 9368c2ecf20Sopenharmony_ci * 9378c2ecf20Sopenharmony_ci * Driver loads FH49_KW_MEM_ADDR_REG with the physical address (bits 35:4) 9388c2ecf20Sopenharmony_ci * of the buffer, which must be 4K aligned. Once this is set up, the 4965 9398c2ecf20Sopenharmony_ci * automatically invokes keep-warm accesses when normal accesses might not 9408c2ecf20Sopenharmony_ci * be sufficient to maintain fast DRAM response. 9418c2ecf20Sopenharmony_ci * 9428c2ecf20Sopenharmony_ci * Bit fields: 9438c2ecf20Sopenharmony_ci * 31-0: Keep-warm buffer physical base address [35:4], must be 4K aligned 9448c2ecf20Sopenharmony_ci */ 9458c2ecf20Sopenharmony_ci#define FH49_KW_MEM_ADDR_REG (FH49_MEM_LOWER_BOUND + 0x97C) 9468c2ecf20Sopenharmony_ci 9478c2ecf20Sopenharmony_ci/** 9488c2ecf20Sopenharmony_ci * TFD Circular Buffers Base (CBBC) addresses 9498c2ecf20Sopenharmony_ci * 9508c2ecf20Sopenharmony_ci * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident 9518c2ecf20Sopenharmony_ci * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs) 9528c2ecf20Sopenharmony_ci * (see struct il_tfd_frame). These 16 pointer registers are offset by 0x04 9538c2ecf20Sopenharmony_ci * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte 9548c2ecf20Sopenharmony_ci * aligned (address bits 0-7 must be 0). 9558c2ecf20Sopenharmony_ci * 9568c2ecf20Sopenharmony_ci * Bit fields in each pointer register: 9578c2ecf20Sopenharmony_ci * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned 9588c2ecf20Sopenharmony_ci */ 9598c2ecf20Sopenharmony_ci#define FH49_MEM_CBBC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0) 9608c2ecf20Sopenharmony_ci#define FH49_MEM_CBBC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xA10) 9618c2ecf20Sopenharmony_ci 9628c2ecf20Sopenharmony_ci/* Find TFD CB base pointer for given queue (range 0-15). */ 9638c2ecf20Sopenharmony_ci#define FH49_MEM_CBBC_QUEUE(x) (FH49_MEM_CBBC_LOWER_BOUND + (x) * 0x4) 9648c2ecf20Sopenharmony_ci 9658c2ecf20Sopenharmony_ci/** 9668c2ecf20Sopenharmony_ci * Rx SRAM Control and Status Registers (RSCSR) 9678c2ecf20Sopenharmony_ci * 9688c2ecf20Sopenharmony_ci * These registers provide handshake between driver and 4965 for the Rx queue 9698c2ecf20Sopenharmony_ci * (this queue handles *all* command responses, notifications, Rx data, etc. 9708c2ecf20Sopenharmony_ci * sent from 4965 uCode to host driver). Unlike Tx, there is only one Rx 9718c2ecf20Sopenharmony_ci * queue, and only one Rx DMA/FIFO channel. Also unlike Tx, which can 9728c2ecf20Sopenharmony_ci * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer 9738c2ecf20Sopenharmony_ci * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1 9748c2ecf20Sopenharmony_ci * mapping between RBDs and RBs. 9758c2ecf20Sopenharmony_ci * 9768c2ecf20Sopenharmony_ci * Driver must allocate host DRAM memory for the following, and set the 9778c2ecf20Sopenharmony_ci * physical address of each into 4965 registers: 9788c2ecf20Sopenharmony_ci * 9798c2ecf20Sopenharmony_ci * 1) Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256 9808c2ecf20Sopenharmony_ci * entries (although any power of 2, up to 4096, is selectable by driver). 9818c2ecf20Sopenharmony_ci * Each entry (1 dword) points to a receive buffer (RB) of consistent size 9828c2ecf20Sopenharmony_ci * (typically 4K, although 8K or 16K are also selectable by driver). 9838c2ecf20Sopenharmony_ci * Driver sets up RB size and number of RBDs in the CB via Rx config 9848c2ecf20Sopenharmony_ci * register FH49_MEM_RCSR_CHNL0_CONFIG_REG. 9858c2ecf20Sopenharmony_ci * 9868c2ecf20Sopenharmony_ci * Bit fields within one RBD: 9878c2ecf20Sopenharmony_ci * 27-0: Receive Buffer physical address bits [35:8], 256-byte aligned 9888c2ecf20Sopenharmony_ci * 9898c2ecf20Sopenharmony_ci * Driver sets physical address [35:8] of base of RBD circular buffer 9908c2ecf20Sopenharmony_ci * into FH49_RSCSR_CHNL0_RBDCB_BASE_REG [27:0]. 9918c2ecf20Sopenharmony_ci * 9928c2ecf20Sopenharmony_ci * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers 9938c2ecf20Sopenharmony_ci * (RBs) have been filled, via a "write pointer", actually the idx of 9948c2ecf20Sopenharmony_ci * the RB's corresponding RBD within the circular buffer. Driver sets 9958c2ecf20Sopenharmony_ci * physical address [35:4] into FH49_RSCSR_CHNL0_STTS_WPTR_REG [31:0]. 9968c2ecf20Sopenharmony_ci * 9978c2ecf20Sopenharmony_ci * Bit fields in lower dword of Rx status buffer (upper dword not used 9988c2ecf20Sopenharmony_ci * by driver; see struct il4965_shared, val0): 9998c2ecf20Sopenharmony_ci * 31-12: Not used by driver 10008c2ecf20Sopenharmony_ci * 11- 0: Index of last filled Rx buffer descriptor 10018c2ecf20Sopenharmony_ci * (4965 writes, driver reads this value) 10028c2ecf20Sopenharmony_ci * 10038c2ecf20Sopenharmony_ci * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must 10048c2ecf20Sopenharmony_ci * enter pointers to these RBs into contiguous RBD circular buffer entries, 10058c2ecf20Sopenharmony_ci * and update the 4965's "write" idx register, 10068c2ecf20Sopenharmony_ci * FH49_RSCSR_CHNL0_RBDCB_WPTR_REG. 10078c2ecf20Sopenharmony_ci * 10088c2ecf20Sopenharmony_ci * This "write" idx corresponds to the *next* RBD that the driver will make 10098c2ecf20Sopenharmony_ci * available, i.e. one RBD past the tail of the ready-to-fill RBDs within 10108c2ecf20Sopenharmony_ci * the circular buffer. This value should initially be 0 (before preparing any 10118c2ecf20Sopenharmony_ci * RBs), should be 8 after preparing the first 8 RBs (for example), and must 10128c2ecf20Sopenharmony_ci * wrap back to 0 at the end of the circular buffer (but don't wrap before 10138c2ecf20Sopenharmony_ci * "read" idx has advanced past 1! See below). 10148c2ecf20Sopenharmony_ci * NOTE: 4965 EXPECTS THE WRITE IDX TO BE INCREMENTED IN MULTIPLES OF 8. 10158c2ecf20Sopenharmony_ci * 10168c2ecf20Sopenharmony_ci * As the 4965 fills RBs (referenced from contiguous RBDs within the circular 10178c2ecf20Sopenharmony_ci * buffer), it updates the Rx status buffer in host DRAM, 2) described above, 10188c2ecf20Sopenharmony_ci * to tell the driver the idx of the latest filled RBD. The driver must 10198c2ecf20Sopenharmony_ci * read this "read" idx from DRAM after receiving an Rx interrupt from 4965. 10208c2ecf20Sopenharmony_ci * 10218c2ecf20Sopenharmony_ci * The driver must also internally keep track of a third idx, which is the 10228c2ecf20Sopenharmony_ci * next RBD to process. When receiving an Rx interrupt, driver should process 10238c2ecf20Sopenharmony_ci * all filled but unprocessed RBs up to, but not including, the RB 10248c2ecf20Sopenharmony_ci * corresponding to the "read" idx. For example, if "read" idx becomes "1", 10258c2ecf20Sopenharmony_ci * driver may process the RB pointed to by RBD 0. Depending on volume of 10268c2ecf20Sopenharmony_ci * traffic, there may be many RBs to process. 10278c2ecf20Sopenharmony_ci * 10288c2ecf20Sopenharmony_ci * If read idx == write idx, 4965 thinks there is no room to put new data. 10298c2ecf20Sopenharmony_ci * Due to this, the maximum number of filled RBs is 255, instead of 256. To 10308c2ecf20Sopenharmony_ci * be safe, make sure that there is a gap of at least 2 RBDs between "write" 10318c2ecf20Sopenharmony_ci * and "read" idxes; that is, make sure that there are no more than 254 10328c2ecf20Sopenharmony_ci * buffers waiting to be filled. 10338c2ecf20Sopenharmony_ci */ 10348c2ecf20Sopenharmony_ci#define FH49_MEM_RSCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xBC0) 10358c2ecf20Sopenharmony_ci#define FH49_MEM_RSCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00) 10368c2ecf20Sopenharmony_ci#define FH49_MEM_RSCSR_CHNL0 (FH49_MEM_RSCSR_LOWER_BOUND) 10378c2ecf20Sopenharmony_ci 10388c2ecf20Sopenharmony_ci/** 10398c2ecf20Sopenharmony_ci * Physical base address of 8-byte Rx Status buffer. 10408c2ecf20Sopenharmony_ci * Bit fields: 10418c2ecf20Sopenharmony_ci * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned. 10428c2ecf20Sopenharmony_ci */ 10438c2ecf20Sopenharmony_ci#define FH49_RSCSR_CHNL0_STTS_WPTR_REG (FH49_MEM_RSCSR_CHNL0) 10448c2ecf20Sopenharmony_ci 10458c2ecf20Sopenharmony_ci/** 10468c2ecf20Sopenharmony_ci * Physical base address of Rx Buffer Descriptor Circular Buffer. 10478c2ecf20Sopenharmony_ci * Bit fields: 10488c2ecf20Sopenharmony_ci * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned. 10498c2ecf20Sopenharmony_ci */ 10508c2ecf20Sopenharmony_ci#define FH49_RSCSR_CHNL0_RBDCB_BASE_REG (FH49_MEM_RSCSR_CHNL0 + 0x004) 10518c2ecf20Sopenharmony_ci 10528c2ecf20Sopenharmony_ci/** 10538c2ecf20Sopenharmony_ci * Rx write pointer (idx, really!). 10548c2ecf20Sopenharmony_ci * Bit fields: 10558c2ecf20Sopenharmony_ci * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1. 10568c2ecf20Sopenharmony_ci * NOTE: For 256-entry circular buffer, use only bits [7:0]. 10578c2ecf20Sopenharmony_ci */ 10588c2ecf20Sopenharmony_ci#define FH49_RSCSR_CHNL0_RBDCB_WPTR_REG (FH49_MEM_RSCSR_CHNL0 + 0x008) 10598c2ecf20Sopenharmony_ci#define FH49_RSCSR_CHNL0_WPTR (FH49_RSCSR_CHNL0_RBDCB_WPTR_REG) 10608c2ecf20Sopenharmony_ci 10618c2ecf20Sopenharmony_ci/** 10628c2ecf20Sopenharmony_ci * Rx Config/Status Registers (RCSR) 10638c2ecf20Sopenharmony_ci * Rx Config Reg for channel 0 (only channel used) 10648c2ecf20Sopenharmony_ci * 10658c2ecf20Sopenharmony_ci * Driver must initialize FH49_MEM_RCSR_CHNL0_CONFIG_REG as follows for 10668c2ecf20Sopenharmony_ci * normal operation (see bit fields). 10678c2ecf20Sopenharmony_ci * 10688c2ecf20Sopenharmony_ci * Clearing FH49_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA. 10698c2ecf20Sopenharmony_ci * Driver should poll FH49_MEM_RSSR_RX_STATUS_REG for 10708c2ecf20Sopenharmony_ci * FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing. 10718c2ecf20Sopenharmony_ci * 10728c2ecf20Sopenharmony_ci * Bit fields: 10738c2ecf20Sopenharmony_ci * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame, 10748c2ecf20Sopenharmony_ci * '10' operate normally 10758c2ecf20Sopenharmony_ci * 29-24: reserved 10768c2ecf20Sopenharmony_ci * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal), 10778c2ecf20Sopenharmony_ci * min "5" for 32 RBDs, max "12" for 4096 RBDs. 10788c2ecf20Sopenharmony_ci * 19-18: reserved 10798c2ecf20Sopenharmony_ci * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K, 10808c2ecf20Sopenharmony_ci * '10' 12K, '11' 16K. 10818c2ecf20Sopenharmony_ci * 15-14: reserved 10828c2ecf20Sopenharmony_ci * 13-12: IRQ destination; '00' none, '01' host driver (normal operation) 10838c2ecf20Sopenharmony_ci * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec) 10848c2ecf20Sopenharmony_ci * typical value 0x10 (about 1/2 msec) 10858c2ecf20Sopenharmony_ci * 3- 0: reserved 10868c2ecf20Sopenharmony_ci */ 10878c2ecf20Sopenharmony_ci#define FH49_MEM_RCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00) 10888c2ecf20Sopenharmony_ci#define FH49_MEM_RCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xCC0) 10898c2ecf20Sopenharmony_ci#define FH49_MEM_RCSR_CHNL0 (FH49_MEM_RCSR_LOWER_BOUND) 10908c2ecf20Sopenharmony_ci 10918c2ecf20Sopenharmony_ci#define FH49_MEM_RCSR_CHNL0_CONFIG_REG (FH49_MEM_RCSR_CHNL0) 10928c2ecf20Sopenharmony_ci 10938c2ecf20Sopenharmony_ci#define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */ 10948c2ecf20Sopenharmony_ci#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */ 10958c2ecf20Sopenharmony_ci#define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */ 10968c2ecf20Sopenharmony_ci#define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */ 10978c2ecf20Sopenharmony_ci#define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */ 10988c2ecf20Sopenharmony_ci#define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31 */ 10998c2ecf20Sopenharmony_ci 11008c2ecf20Sopenharmony_ci#define FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20) 11018c2ecf20Sopenharmony_ci#define FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4) 11028c2ecf20Sopenharmony_ci#define RX_RB_TIMEOUT (0x10) 11038c2ecf20Sopenharmony_ci 11048c2ecf20Sopenharmony_ci#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000) 11058c2ecf20Sopenharmony_ci#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000) 11068c2ecf20Sopenharmony_ci#define FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000) 11078c2ecf20Sopenharmony_ci 11088c2ecf20Sopenharmony_ci#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000) 11098c2ecf20Sopenharmony_ci#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000) 11108c2ecf20Sopenharmony_ci#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000) 11118c2ecf20Sopenharmony_ci#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000) 11128c2ecf20Sopenharmony_ci 11138c2ecf20Sopenharmony_ci#define FH49_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY (0x00000004) 11148c2ecf20Sopenharmony_ci#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000) 11158c2ecf20Sopenharmony_ci#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000) 11168c2ecf20Sopenharmony_ci 11178c2ecf20Sopenharmony_ci/** 11188c2ecf20Sopenharmony_ci * Rx Shared Status Registers (RSSR) 11198c2ecf20Sopenharmony_ci * 11208c2ecf20Sopenharmony_ci * After stopping Rx DMA channel (writing 0 to 11218c2ecf20Sopenharmony_ci * FH49_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll 11228c2ecf20Sopenharmony_ci * FH49_MEM_RSSR_RX_STATUS_REG until Rx channel is idle. 11238c2ecf20Sopenharmony_ci * 11248c2ecf20Sopenharmony_ci * Bit fields: 11258c2ecf20Sopenharmony_ci * 24: 1 = Channel 0 is idle 11268c2ecf20Sopenharmony_ci * 11278c2ecf20Sopenharmony_ci * FH49_MEM_RSSR_SHARED_CTRL_REG and FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV 11288c2ecf20Sopenharmony_ci * contain default values that should not be altered by the driver. 11298c2ecf20Sopenharmony_ci */ 11308c2ecf20Sopenharmony_ci#define FH49_MEM_RSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC40) 11318c2ecf20Sopenharmony_ci#define FH49_MEM_RSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00) 11328c2ecf20Sopenharmony_ci 11338c2ecf20Sopenharmony_ci#define FH49_MEM_RSSR_SHARED_CTRL_REG (FH49_MEM_RSSR_LOWER_BOUND) 11348c2ecf20Sopenharmony_ci#define FH49_MEM_RSSR_RX_STATUS_REG (FH49_MEM_RSSR_LOWER_BOUND + 0x004) 11358c2ecf20Sopenharmony_ci#define FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\ 11368c2ecf20Sopenharmony_ci (FH49_MEM_RSSR_LOWER_BOUND + 0x008) 11378c2ecf20Sopenharmony_ci 11388c2ecf20Sopenharmony_ci#define FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) 11398c2ecf20Sopenharmony_ci 11408c2ecf20Sopenharmony_ci#define FH49_MEM_TFDIB_REG1_ADDR_BITSHIFT 28 11418c2ecf20Sopenharmony_ci 11428c2ecf20Sopenharmony_ci/* TFDB Area - TFDs buffer table */ 11438c2ecf20Sopenharmony_ci#define FH49_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF) 11448c2ecf20Sopenharmony_ci#define FH49_TFDIB_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x900) 11458c2ecf20Sopenharmony_ci#define FH49_TFDIB_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x958) 11468c2ecf20Sopenharmony_ci#define FH49_TFDIB_CTRL0_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl)) 11478c2ecf20Sopenharmony_ci#define FH49_TFDIB_CTRL1_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4) 11488c2ecf20Sopenharmony_ci 11498c2ecf20Sopenharmony_ci/** 11508c2ecf20Sopenharmony_ci * Transmit DMA Channel Control/Status Registers (TCSR) 11518c2ecf20Sopenharmony_ci * 11528c2ecf20Sopenharmony_ci * 4965 has one configuration register for each of 8 Tx DMA/FIFO channels 11538c2ecf20Sopenharmony_ci * supported in hardware (don't confuse these with the 16 Tx queues in DRAM, 11548c2ecf20Sopenharmony_ci * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes. 11558c2ecf20Sopenharmony_ci * 11568c2ecf20Sopenharmony_ci * To use a Tx DMA channel, driver must initialize its 11578c2ecf20Sopenharmony_ci * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl) with: 11588c2ecf20Sopenharmony_ci * 11598c2ecf20Sopenharmony_ci * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | 11608c2ecf20Sopenharmony_ci * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL 11618c2ecf20Sopenharmony_ci * 11628c2ecf20Sopenharmony_ci * All other bits should be 0. 11638c2ecf20Sopenharmony_ci * 11648c2ecf20Sopenharmony_ci * Bit fields: 11658c2ecf20Sopenharmony_ci * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame, 11668c2ecf20Sopenharmony_ci * '10' operate normally 11678c2ecf20Sopenharmony_ci * 29- 4: Reserved, set to "0" 11688c2ecf20Sopenharmony_ci * 3: Enable internal DMA requests (1, normal operation), disable (0) 11698c2ecf20Sopenharmony_ci * 2- 0: Reserved, set to "0" 11708c2ecf20Sopenharmony_ci */ 11718c2ecf20Sopenharmony_ci#define FH49_TCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00) 11728c2ecf20Sopenharmony_ci#define FH49_TCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xE60) 11738c2ecf20Sopenharmony_ci 11748c2ecf20Sopenharmony_ci/* Find Control/Status reg for given Tx DMA/FIFO channel */ 11758c2ecf20Sopenharmony_ci#define FH49_TCSR_CHNL_NUM (7) 11768c2ecf20Sopenharmony_ci#define FH50_TCSR_CHNL_NUM (8) 11778c2ecf20Sopenharmony_ci 11788c2ecf20Sopenharmony_ci/* TCSR: tx_config register values */ 11798c2ecf20Sopenharmony_ci#define FH49_TCSR_CHNL_TX_CONFIG_REG(_chnl) \ 11808c2ecf20Sopenharmony_ci (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl)) 11818c2ecf20Sopenharmony_ci#define FH49_TCSR_CHNL_TX_CREDIT_REG(_chnl) \ 11828c2ecf20Sopenharmony_ci (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4) 11838c2ecf20Sopenharmony_ci#define FH49_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \ 11848c2ecf20Sopenharmony_ci (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8) 11858c2ecf20Sopenharmony_ci 11868c2ecf20Sopenharmony_ci#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000) 11878c2ecf20Sopenharmony_ci#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV (0x00000001) 11888c2ecf20Sopenharmony_ci 11898c2ecf20Sopenharmony_ci#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE (0x00000000) 11908c2ecf20Sopenharmony_ci#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE (0x00000008) 11918c2ecf20Sopenharmony_ci 11928c2ecf20Sopenharmony_ci#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000) 11938c2ecf20Sopenharmony_ci#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000) 11948c2ecf20Sopenharmony_ci#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000) 11958c2ecf20Sopenharmony_ci 11968c2ecf20Sopenharmony_ci#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000) 11978c2ecf20Sopenharmony_ci#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000) 11988c2ecf20Sopenharmony_ci#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000) 11998c2ecf20Sopenharmony_ci 12008c2ecf20Sopenharmony_ci#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) 12018c2ecf20Sopenharmony_ci#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000) 12028c2ecf20Sopenharmony_ci#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000) 12038c2ecf20Sopenharmony_ci 12048c2ecf20Sopenharmony_ci#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000) 12058c2ecf20Sopenharmony_ci#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000) 12068c2ecf20Sopenharmony_ci#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003) 12078c2ecf20Sopenharmony_ci 12088c2ecf20Sopenharmony_ci#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20) 12098c2ecf20Sopenharmony_ci#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12) 12108c2ecf20Sopenharmony_ci 12118c2ecf20Sopenharmony_ci/** 12128c2ecf20Sopenharmony_ci * Tx Shared Status Registers (TSSR) 12138c2ecf20Sopenharmony_ci * 12148c2ecf20Sopenharmony_ci * After stopping Tx DMA channel (writing 0 to 12158c2ecf20Sopenharmony_ci * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll 12168c2ecf20Sopenharmony_ci * FH49_TSSR_TX_STATUS_REG until selected Tx channel is idle 12178c2ecf20Sopenharmony_ci * (channel's buffers empty | no pending requests). 12188c2ecf20Sopenharmony_ci * 12198c2ecf20Sopenharmony_ci * Bit fields: 12208c2ecf20Sopenharmony_ci * 31-24: 1 = Channel buffers empty (channel 7:0) 12218c2ecf20Sopenharmony_ci * 23-16: 1 = No pending requests (channel 7:0) 12228c2ecf20Sopenharmony_ci */ 12238c2ecf20Sopenharmony_ci#define FH49_TSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xEA0) 12248c2ecf20Sopenharmony_ci#define FH49_TSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xEC0) 12258c2ecf20Sopenharmony_ci 12268c2ecf20Sopenharmony_ci#define FH49_TSSR_TX_STATUS_REG (FH49_TSSR_LOWER_BOUND + 0x010) 12278c2ecf20Sopenharmony_ci 12288c2ecf20Sopenharmony_ci/** 12298c2ecf20Sopenharmony_ci * Bit fields for TSSR(Tx Shared Status & Control) error status register: 12308c2ecf20Sopenharmony_ci * 31: Indicates an address error when accessed to internal memory 12318c2ecf20Sopenharmony_ci * uCode/driver must write "1" in order to clear this flag 12328c2ecf20Sopenharmony_ci * 30: Indicates that Host did not send the expected number of dwords to FH 12338c2ecf20Sopenharmony_ci * uCode/driver must write "1" in order to clear this flag 12348c2ecf20Sopenharmony_ci * 16-9:Each status bit is for one channel. Indicates that an (Error) ActDMA 12358c2ecf20Sopenharmony_ci * command was received from the scheduler while the TRB was already full 12368c2ecf20Sopenharmony_ci * with previous command 12378c2ecf20Sopenharmony_ci * uCode/driver must write "1" in order to clear this flag 12388c2ecf20Sopenharmony_ci * 7-0: Each status bit indicates a channel's TxCredit error. When an error 12398c2ecf20Sopenharmony_ci * bit is set, it indicates that the FH has received a full indication 12408c2ecf20Sopenharmony_ci * from the RTC TxFIFO and the current value of the TxCredit counter was 12418c2ecf20Sopenharmony_ci * not equal to zero. This mean that the credit mechanism was not 12428c2ecf20Sopenharmony_ci * synchronized to the TxFIFO status 12438c2ecf20Sopenharmony_ci * uCode/driver must write "1" in order to clear this flag 12448c2ecf20Sopenharmony_ci */ 12458c2ecf20Sopenharmony_ci#define FH49_TSSR_TX_ERROR_REG (FH49_TSSR_LOWER_BOUND + 0x018) 12468c2ecf20Sopenharmony_ci 12478c2ecf20Sopenharmony_ci#define FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16) 12488c2ecf20Sopenharmony_ci 12498c2ecf20Sopenharmony_ci/* Tx service channels */ 12508c2ecf20Sopenharmony_ci#define FH49_SRVC_CHNL (9) 12518c2ecf20Sopenharmony_ci#define FH49_SRVC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9C8) 12528c2ecf20Sopenharmony_ci#define FH49_SRVC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0) 12538c2ecf20Sopenharmony_ci#define FH49_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \ 12548c2ecf20Sopenharmony_ci (FH49_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4) 12558c2ecf20Sopenharmony_ci 12568c2ecf20Sopenharmony_ci#define FH49_TX_CHICKEN_BITS_REG (FH49_MEM_LOWER_BOUND + 0xE98) 12578c2ecf20Sopenharmony_ci/* Instruct FH to increment the retry count of a packet when 12588c2ecf20Sopenharmony_ci * it is brought from the memory to TX-FIFO 12598c2ecf20Sopenharmony_ci */ 12608c2ecf20Sopenharmony_ci#define FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002) 12618c2ecf20Sopenharmony_ci 12628c2ecf20Sopenharmony_ci/* Keep Warm Size */ 12638c2ecf20Sopenharmony_ci#define IL_KW_SIZE 0x1000 /* 4k */ 12648c2ecf20Sopenharmony_ci 12658c2ecf20Sopenharmony_ci#endif /* __il_4965_h__ */ 1266