162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright (c) 2014 Redpine Signals Inc. 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any 562306a36Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above 662306a36Sopenharmony_ci * copyright notice and this permission notice appear in all copies. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 962306a36Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1062306a36Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1162306a36Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1262306a36Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1362306a36Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1462306a36Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1562306a36Sopenharmony_ci */ 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#ifndef __RSI_BOOTPARAMS_HEADER_H__ 1862306a36Sopenharmony_ci#define __RSI_BOOTPARAMS_HEADER_H__ 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#define CRYSTAL_GOOD_TIME BIT(0) 2162306a36Sopenharmony_ci#define BOOTUP_MODE_INFO BIT(1) 2262306a36Sopenharmony_ci#define WIFI_TAPLL_CONFIGS BIT(5) 2362306a36Sopenharmony_ci#define WIFI_PLL960_CONFIGS BIT(6) 2462306a36Sopenharmony_ci#define WIFI_AFEPLL_CONFIGS BIT(7) 2562306a36Sopenharmony_ci#define WIFI_SWITCH_CLK_CONFIGS BIT(8) 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#define TA_PLL_M_VAL_20 9 2862306a36Sopenharmony_ci#define TA_PLL_N_VAL_20 0 2962306a36Sopenharmony_ci#define TA_PLL_P_VAL_20 4 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci#define PLL960_M_VAL_20 0x14 3262306a36Sopenharmony_ci#define PLL960_N_VAL_20 0 3362306a36Sopenharmony_ci#define PLL960_P_VAL_20 5 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#define UMAC_CLK_40MHZ 80 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci#define TA_PLL_M_VAL_40 9 3862306a36Sopenharmony_ci#define TA_PLL_N_VAL_40 0 3962306a36Sopenharmony_ci#define TA_PLL_P_VAL_40 4 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci#define PLL960_M_VAL_40 0x14 4262306a36Sopenharmony_ci#define PLL960_N_VAL_40 0 4362306a36Sopenharmony_ci#define PLL960_P_VAL_40 5 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci#define UMAC_CLK_20BW \ 4662306a36Sopenharmony_ci (((TA_PLL_M_VAL_20 + 1) * 40) / \ 4762306a36Sopenharmony_ci ((TA_PLL_N_VAL_20 + 1) * (TA_PLL_P_VAL_20 + 1))) 4862306a36Sopenharmony_ci#define VALID_20 \ 4962306a36Sopenharmony_ci (WIFI_TAPLL_CONFIGS | WIFI_PLL960_CONFIGS | WIFI_AFEPLL_CONFIGS | \ 5062306a36Sopenharmony_ci WIFI_SWITCH_CLK_CONFIGS | BOOTUP_MODE_INFO | CRYSTAL_GOOD_TIME) 5162306a36Sopenharmony_ci#define UMAC_CLK_40BW \ 5262306a36Sopenharmony_ci (((TA_PLL_M_VAL_40 + 1) * 40) / \ 5362306a36Sopenharmony_ci ((TA_PLL_N_VAL_40 + 1) * (TA_PLL_P_VAL_40 + 1))) 5462306a36Sopenharmony_ci#define VALID_40 \ 5562306a36Sopenharmony_ci (WIFI_PLL960_CONFIGS | WIFI_AFEPLL_CONFIGS | WIFI_SWITCH_CLK_CONFIGS | \ 5662306a36Sopenharmony_ci WIFI_TAPLL_CONFIGS | CRYSTAL_GOOD_TIME | BOOTUP_MODE_INFO) 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci/* structure to store configs related to TAPLL programming */ 5962306a36Sopenharmony_cistruct tapll_info { 6062306a36Sopenharmony_ci __le16 pll_reg_1; 6162306a36Sopenharmony_ci __le16 pll_reg_2; 6262306a36Sopenharmony_ci} __packed; 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci/* structure to store configs related to PLL960 programming */ 6562306a36Sopenharmony_cistruct pll960_info { 6662306a36Sopenharmony_ci __le16 pll_reg_1; 6762306a36Sopenharmony_ci __le16 pll_reg_2; 6862306a36Sopenharmony_ci __le16 pll_reg_3; 6962306a36Sopenharmony_ci} __packed; 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci/* structure to store configs related to AFEPLL programming */ 7262306a36Sopenharmony_cistruct afepll_info { 7362306a36Sopenharmony_ci __le16 pll_reg; 7462306a36Sopenharmony_ci} __packed; 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci/* structure to store configs related to pll configs */ 7762306a36Sopenharmony_cistruct pll_config { 7862306a36Sopenharmony_ci struct tapll_info tapll_info_g; 7962306a36Sopenharmony_ci struct pll960_info pll960_info_g; 8062306a36Sopenharmony_ci struct afepll_info afepll_info_g; 8162306a36Sopenharmony_ci} __packed; 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_cistruct pll_config_9116 { 8462306a36Sopenharmony_ci __le16 pll_ctrl_set_reg; 8562306a36Sopenharmony_ci __le16 pll_ctrl_clr_reg; 8662306a36Sopenharmony_ci __le16 pll_modem_conig_reg; 8762306a36Sopenharmony_ci __le16 soc_clk_config_reg; 8862306a36Sopenharmony_ci __le16 adc_dac_strm1_config_reg; 8962306a36Sopenharmony_ci __le16 adc_dac_strm2_config_reg; 9062306a36Sopenharmony_ci} __packed; 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci/* structure to store configs related to UMAC clk programming */ 9362306a36Sopenharmony_cistruct switch_clk { 9462306a36Sopenharmony_ci __le16 switch_clk_info; 9562306a36Sopenharmony_ci /* If switch_bbp_lmac_clk_reg is set then this value will be programmed 9662306a36Sopenharmony_ci * into reg 9762306a36Sopenharmony_ci */ 9862306a36Sopenharmony_ci __le16 bbp_lmac_clk_reg_val; 9962306a36Sopenharmony_ci /* if switch_umac_clk is set then this value will be programmed */ 10062306a36Sopenharmony_ci __le16 umac_clock_reg_config; 10162306a36Sopenharmony_ci /* if switch_qspi_clk is set then this value will be programmed */ 10262306a36Sopenharmony_ci __le16 qspi_uart_clock_reg_config; 10362306a36Sopenharmony_ci} __packed; 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci#define RSI_SWITCH_TASS_CLK BIT(0) 10662306a36Sopenharmony_ci#define RSI_SWITCH_QSPI_CLK BIT(1) 10762306a36Sopenharmony_ci#define RSI_SWITCH_SLP_CLK_2_32 BIT(2) 10862306a36Sopenharmony_ci#define RSI_SWITCH_WLAN_BBP_LMAC_CLK_REG BIT(3) 10962306a36Sopenharmony_ci#define RSI_SWITCH_ZBBT_BBP_LMAC_CLK_REG BIT(4) 11062306a36Sopenharmony_ci#define RSI_SWITCH_BBP_LMAC_CLK_REG BIT(5) 11162306a36Sopenharmony_ci#define RSI_MODEM_CLK_160MHZ BIT(6) 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_cistruct switch_clk_9116 { 11462306a36Sopenharmony_ci __le32 switch_clk_info; 11562306a36Sopenharmony_ci __le32 tass_clock_reg; 11662306a36Sopenharmony_ci __le32 wlan_bbp_lmac_clk_reg_val; 11762306a36Sopenharmony_ci __le32 zbbt_bbp_lmac_clk_reg_val; 11862306a36Sopenharmony_ci __le32 bbp_lmac_clk_en_val; 11962306a36Sopenharmony_ci} __packed; 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_cistruct device_clk_info { 12262306a36Sopenharmony_ci struct pll_config pll_config_g; 12362306a36Sopenharmony_ci struct switch_clk switch_clk_g; 12462306a36Sopenharmony_ci} __packed; 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_cistruct device_clk_info_9116 { 12762306a36Sopenharmony_ci struct pll_config_9116 pll_config_9116_g; 12862306a36Sopenharmony_ci struct switch_clk_9116 switch_clk_9116_g; 12962306a36Sopenharmony_ci} __packed; 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_cistruct bootup_params { 13262306a36Sopenharmony_ci __le16 magic_number; 13362306a36Sopenharmony_ci __le16 crystal_good_time; 13462306a36Sopenharmony_ci __le32 valid; 13562306a36Sopenharmony_ci __le32 reserved_for_valids; 13662306a36Sopenharmony_ci __le16 bootup_mode_info; 13762306a36Sopenharmony_ci /* configuration used for digital loop back */ 13862306a36Sopenharmony_ci __le16 digital_loop_back_params; 13962306a36Sopenharmony_ci __le16 rtls_timestamp_en; 14062306a36Sopenharmony_ci __le16 host_spi_intr_cfg; 14162306a36Sopenharmony_ci struct device_clk_info device_clk_info[3]; 14262306a36Sopenharmony_ci /* ulp buckboost wait time */ 14362306a36Sopenharmony_ci __le32 buckboost_wakeup_cnt; 14462306a36Sopenharmony_ci /* pmu wakeup wait time & WDT EN info */ 14562306a36Sopenharmony_ci __le16 pmu_wakeup_wait; 14662306a36Sopenharmony_ci u8 shutdown_wait_time; 14762306a36Sopenharmony_ci /* Sleep clock source selection */ 14862306a36Sopenharmony_ci u8 pmu_slp_clkout_sel; 14962306a36Sopenharmony_ci /* WDT programming values */ 15062306a36Sopenharmony_ci __le32 wdt_prog_value; 15162306a36Sopenharmony_ci /* WDT soc reset delay */ 15262306a36Sopenharmony_ci __le32 wdt_soc_rst_delay; 15362306a36Sopenharmony_ci /* dcdc modes configs */ 15462306a36Sopenharmony_ci __le32 dcdc_operation_mode; 15562306a36Sopenharmony_ci __le32 soc_reset_wait_cnt; 15662306a36Sopenharmony_ci __le32 waiting_time_at_fresh_sleep; 15762306a36Sopenharmony_ci __le32 max_threshold_to_avoid_sleep; 15862306a36Sopenharmony_ci u8 beacon_resedue_alg_en; 15962306a36Sopenharmony_ci} __packed; 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_cistruct bootup_params_9116 { 16262306a36Sopenharmony_ci __le16 magic_number; 16362306a36Sopenharmony_ci#define LOADED_TOKEN 0x5AA5 /* Bootup params are installed by host 16462306a36Sopenharmony_ci * or OTP/FLASH (Bootloader) 16562306a36Sopenharmony_ci */ 16662306a36Sopenharmony_ci#define ROM_TOKEN 0x55AA /* Bootup params are taken from ROM 16762306a36Sopenharmony_ci * itself in MCU mode. 16862306a36Sopenharmony_ci */ 16962306a36Sopenharmony_ci __le16 crystal_good_time; 17062306a36Sopenharmony_ci __le32 valid; 17162306a36Sopenharmony_ci __le32 reserved_for_valids; 17262306a36Sopenharmony_ci __le16 bootup_mode_info; 17362306a36Sopenharmony_ci#define BT_COEXIST BIT(0) 17462306a36Sopenharmony_ci#define BOOTUP_MODE (BIT(2) | BIT(1)) 17562306a36Sopenharmony_ci#define CUR_DEV_MODE_9116 (bootup_params_9116.bootup_mode_info >> 1) 17662306a36Sopenharmony_ci __le16 digital_loop_back_params; 17762306a36Sopenharmony_ci __le16 rtls_timestamp_en; 17862306a36Sopenharmony_ci __le16 host_spi_intr_cfg; 17962306a36Sopenharmony_ci struct device_clk_info_9116 device_clk_info_9116[1]; 18062306a36Sopenharmony_ci __le32 buckboost_wakeup_cnt; 18162306a36Sopenharmony_ci __le16 pmu_wakeup_wait; 18262306a36Sopenharmony_ci u8 shutdown_wait_time; 18362306a36Sopenharmony_ci u8 pmu_slp_clkout_sel; 18462306a36Sopenharmony_ci __le32 wdt_prog_value; 18562306a36Sopenharmony_ci __le32 wdt_soc_rst_delay; 18662306a36Sopenharmony_ci __le32 dcdc_operation_mode; 18762306a36Sopenharmony_ci __le32 soc_reset_wait_cnt; 18862306a36Sopenharmony_ci __le32 waiting_time_at_fresh_sleep; 18962306a36Sopenharmony_ci __le32 max_threshold_to_avoid_sleep; 19062306a36Sopenharmony_ci u8 beacon_resedue_alg_en; 19162306a36Sopenharmony_ci} __packed; 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ci#endif 194