18c2ecf20Sopenharmony_ci/**
28c2ecf20Sopenharmony_ci * Copyright (c) 2014 Redpine Signals Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any
58c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above
68c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
98c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
108c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
118c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
128c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
138c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
148c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#ifndef __RSI_BOOTPARAMS_HEADER_H__
188c2ecf20Sopenharmony_ci#define __RSI_BOOTPARAMS_HEADER_H__
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define CRYSTAL_GOOD_TIME                BIT(0)
218c2ecf20Sopenharmony_ci#define BOOTUP_MODE_INFO                 BIT(1)
228c2ecf20Sopenharmony_ci#define WIFI_TAPLL_CONFIGS               BIT(5)
238c2ecf20Sopenharmony_ci#define WIFI_PLL960_CONFIGS              BIT(6)
248c2ecf20Sopenharmony_ci#define WIFI_AFEPLL_CONFIGS              BIT(7)
258c2ecf20Sopenharmony_ci#define WIFI_SWITCH_CLK_CONFIGS          BIT(8)
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define TA_PLL_M_VAL_20                  9
288c2ecf20Sopenharmony_ci#define TA_PLL_N_VAL_20                  0
298c2ecf20Sopenharmony_ci#define TA_PLL_P_VAL_20                  4
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define PLL960_M_VAL_20                  0x14
328c2ecf20Sopenharmony_ci#define PLL960_N_VAL_20                  0
338c2ecf20Sopenharmony_ci#define PLL960_P_VAL_20                  5
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define UMAC_CLK_40MHZ                   80
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define TA_PLL_M_VAL_40                  9
388c2ecf20Sopenharmony_ci#define TA_PLL_N_VAL_40                  0
398c2ecf20Sopenharmony_ci#define TA_PLL_P_VAL_40                  4
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define PLL960_M_VAL_40                  0x14
428c2ecf20Sopenharmony_ci#define PLL960_N_VAL_40                  0
438c2ecf20Sopenharmony_ci#define PLL960_P_VAL_40                  5
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define UMAC_CLK_20BW \
468c2ecf20Sopenharmony_ci	(((TA_PLL_M_VAL_20 + 1) * 40) / \
478c2ecf20Sopenharmony_ci	 ((TA_PLL_N_VAL_20 + 1) * (TA_PLL_P_VAL_20 + 1)))
488c2ecf20Sopenharmony_ci#define VALID_20 \
498c2ecf20Sopenharmony_ci	(WIFI_TAPLL_CONFIGS | WIFI_PLL960_CONFIGS | WIFI_AFEPLL_CONFIGS | \
508c2ecf20Sopenharmony_ci	 WIFI_SWITCH_CLK_CONFIGS | BOOTUP_MODE_INFO | CRYSTAL_GOOD_TIME)
518c2ecf20Sopenharmony_ci#define UMAC_CLK_40BW   \
528c2ecf20Sopenharmony_ci	(((TA_PLL_M_VAL_40 + 1) * 40) / \
538c2ecf20Sopenharmony_ci	 ((TA_PLL_N_VAL_40 + 1) * (TA_PLL_P_VAL_40 + 1)))
548c2ecf20Sopenharmony_ci#define VALID_40 \
558c2ecf20Sopenharmony_ci	(WIFI_PLL960_CONFIGS | WIFI_AFEPLL_CONFIGS | WIFI_SWITCH_CLK_CONFIGS | \
568c2ecf20Sopenharmony_ci	 WIFI_TAPLL_CONFIGS | CRYSTAL_GOOD_TIME | BOOTUP_MODE_INFO)
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/* structure to store configs related to TAPLL programming */
598c2ecf20Sopenharmony_cistruct tapll_info {
608c2ecf20Sopenharmony_ci	__le16 pll_reg_1;
618c2ecf20Sopenharmony_ci	__le16 pll_reg_2;
628c2ecf20Sopenharmony_ci} __packed;
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci/* structure to store configs related to PLL960 programming */
658c2ecf20Sopenharmony_cistruct pll960_info {
668c2ecf20Sopenharmony_ci	__le16 pll_reg_1;
678c2ecf20Sopenharmony_ci	__le16 pll_reg_2;
688c2ecf20Sopenharmony_ci	__le16 pll_reg_3;
698c2ecf20Sopenharmony_ci} __packed;
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci/* structure to store configs related to AFEPLL programming */
728c2ecf20Sopenharmony_cistruct afepll_info {
738c2ecf20Sopenharmony_ci	__le16 pll_reg;
748c2ecf20Sopenharmony_ci} __packed;
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci/* structure to store configs related to pll configs */
778c2ecf20Sopenharmony_cistruct pll_config {
788c2ecf20Sopenharmony_ci	struct tapll_info tapll_info_g;
798c2ecf20Sopenharmony_ci	struct pll960_info pll960_info_g;
808c2ecf20Sopenharmony_ci	struct afepll_info afepll_info_g;
818c2ecf20Sopenharmony_ci} __packed;
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cistruct pll_config_9116 {
848c2ecf20Sopenharmony_ci	__le16 pll_ctrl_set_reg;
858c2ecf20Sopenharmony_ci	__le16 pll_ctrl_clr_reg;
868c2ecf20Sopenharmony_ci	__le16 pll_modem_conig_reg;
878c2ecf20Sopenharmony_ci	__le16 soc_clk_config_reg;
888c2ecf20Sopenharmony_ci	__le16 adc_dac_strm1_config_reg;
898c2ecf20Sopenharmony_ci	__le16 adc_dac_strm2_config_reg;
908c2ecf20Sopenharmony_ci} __packed;
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci/* structure to store configs related to UMAC clk programming */
938c2ecf20Sopenharmony_cistruct switch_clk {
948c2ecf20Sopenharmony_ci	__le16 switch_clk_info;
958c2ecf20Sopenharmony_ci	/* If switch_bbp_lmac_clk_reg is set then this value will be programmed
968c2ecf20Sopenharmony_ci	 * into reg
978c2ecf20Sopenharmony_ci	 */
988c2ecf20Sopenharmony_ci	__le16 bbp_lmac_clk_reg_val;
998c2ecf20Sopenharmony_ci	/* if switch_umac_clk is set then this value will be programmed */
1008c2ecf20Sopenharmony_ci	__le16 umac_clock_reg_config;
1018c2ecf20Sopenharmony_ci	/* if switch_qspi_clk is set then this value will be programmed */
1028c2ecf20Sopenharmony_ci	__le16 qspi_uart_clock_reg_config;
1038c2ecf20Sopenharmony_ci} __packed;
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci#define RSI_SWITCH_TASS_CLK			BIT(0)
1068c2ecf20Sopenharmony_ci#define RSI_SWITCH_QSPI_CLK			BIT(1)
1078c2ecf20Sopenharmony_ci#define RSI_SWITCH_SLP_CLK_2_32			BIT(2)
1088c2ecf20Sopenharmony_ci#define RSI_SWITCH_WLAN_BBP_LMAC_CLK_REG	BIT(3)
1098c2ecf20Sopenharmony_ci#define RSI_SWITCH_ZBBT_BBP_LMAC_CLK_REG	BIT(4)
1108c2ecf20Sopenharmony_ci#define RSI_SWITCH_BBP_LMAC_CLK_REG		BIT(5)
1118c2ecf20Sopenharmony_ci#define RSI_MODEM_CLK_160MHZ			BIT(6)
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_cistruct switch_clk_9116 {
1148c2ecf20Sopenharmony_ci	__le32 switch_clk_info;
1158c2ecf20Sopenharmony_ci	__le32 tass_clock_reg;
1168c2ecf20Sopenharmony_ci	__le32 wlan_bbp_lmac_clk_reg_val;
1178c2ecf20Sopenharmony_ci	__le32 zbbt_bbp_lmac_clk_reg_val;
1188c2ecf20Sopenharmony_ci	__le32 bbp_lmac_clk_en_val;
1198c2ecf20Sopenharmony_ci} __packed;
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_cistruct device_clk_info {
1228c2ecf20Sopenharmony_ci	struct pll_config pll_config_g;
1238c2ecf20Sopenharmony_ci	struct switch_clk switch_clk_g;
1248c2ecf20Sopenharmony_ci} __packed;
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_cistruct device_clk_info_9116 {
1278c2ecf20Sopenharmony_ci	struct pll_config_9116 pll_config_9116_g;
1288c2ecf20Sopenharmony_ci	struct switch_clk_9116 switch_clk_9116_g;
1298c2ecf20Sopenharmony_ci} __packed;
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_cistruct bootup_params {
1328c2ecf20Sopenharmony_ci	__le16 magic_number;
1338c2ecf20Sopenharmony_ci	__le16 crystal_good_time;
1348c2ecf20Sopenharmony_ci	__le32 valid;
1358c2ecf20Sopenharmony_ci	__le32 reserved_for_valids;
1368c2ecf20Sopenharmony_ci	__le16 bootup_mode_info;
1378c2ecf20Sopenharmony_ci	/* configuration used for digital loop back */
1388c2ecf20Sopenharmony_ci	__le16 digital_loop_back_params;
1398c2ecf20Sopenharmony_ci	__le16 rtls_timestamp_en;
1408c2ecf20Sopenharmony_ci	__le16 host_spi_intr_cfg;
1418c2ecf20Sopenharmony_ci	struct device_clk_info device_clk_info[3];
1428c2ecf20Sopenharmony_ci	/* ulp buckboost wait time  */
1438c2ecf20Sopenharmony_ci	__le32 buckboost_wakeup_cnt;
1448c2ecf20Sopenharmony_ci	/* pmu wakeup wait time & WDT EN info */
1458c2ecf20Sopenharmony_ci	__le16 pmu_wakeup_wait;
1468c2ecf20Sopenharmony_ci	u8 shutdown_wait_time;
1478c2ecf20Sopenharmony_ci	/* Sleep clock source selection */
1488c2ecf20Sopenharmony_ci	u8 pmu_slp_clkout_sel;
1498c2ecf20Sopenharmony_ci	/* WDT programming values */
1508c2ecf20Sopenharmony_ci	__le32 wdt_prog_value;
1518c2ecf20Sopenharmony_ci	/* WDT soc reset delay */
1528c2ecf20Sopenharmony_ci	__le32 wdt_soc_rst_delay;
1538c2ecf20Sopenharmony_ci	/* dcdc modes configs */
1548c2ecf20Sopenharmony_ci	__le32 dcdc_operation_mode;
1558c2ecf20Sopenharmony_ci	__le32 soc_reset_wait_cnt;
1568c2ecf20Sopenharmony_ci	__le32 waiting_time_at_fresh_sleep;
1578c2ecf20Sopenharmony_ci	__le32 max_threshold_to_avoid_sleep;
1588c2ecf20Sopenharmony_ci	u8 beacon_resedue_alg_en;
1598c2ecf20Sopenharmony_ci} __packed;
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_cistruct bootup_params_9116 {
1628c2ecf20Sopenharmony_ci	__le16 magic_number;
1638c2ecf20Sopenharmony_ci#define LOADED_TOKEN  0x5AA5   /* Bootup params are installed by host
1648c2ecf20Sopenharmony_ci				* or OTP/FLASH (Bootloader)
1658c2ecf20Sopenharmony_ci				*/
1668c2ecf20Sopenharmony_ci#define ROM_TOKEN     0x55AA   /* Bootup params are taken from ROM
1678c2ecf20Sopenharmony_ci				* itself in MCU mode.
1688c2ecf20Sopenharmony_ci				*/
1698c2ecf20Sopenharmony_ci	__le16 crystal_good_time;
1708c2ecf20Sopenharmony_ci	__le32 valid;
1718c2ecf20Sopenharmony_ci	__le32 reserved_for_valids;
1728c2ecf20Sopenharmony_ci	__le16 bootup_mode_info;
1738c2ecf20Sopenharmony_ci#define BT_COEXIST		BIT(0)
1748c2ecf20Sopenharmony_ci#define BOOTUP_MODE		(BIT(2) | BIT(1))
1758c2ecf20Sopenharmony_ci#define CUR_DEV_MODE_9116	(bootup_params_9116.bootup_mode_info >> 1)
1768c2ecf20Sopenharmony_ci	__le16 digital_loop_back_params;
1778c2ecf20Sopenharmony_ci	__le16 rtls_timestamp_en;
1788c2ecf20Sopenharmony_ci	__le16 host_spi_intr_cfg;
1798c2ecf20Sopenharmony_ci	struct device_clk_info_9116 device_clk_info_9116[1];
1808c2ecf20Sopenharmony_ci	__le32 buckboost_wakeup_cnt;
1818c2ecf20Sopenharmony_ci	__le16 pmu_wakeup_wait;
1828c2ecf20Sopenharmony_ci	u8 shutdown_wait_time;
1838c2ecf20Sopenharmony_ci	u8 pmu_slp_clkout_sel;
1848c2ecf20Sopenharmony_ci	__le32 wdt_prog_value;
1858c2ecf20Sopenharmony_ci	__le32 wdt_soc_rst_delay;
1868c2ecf20Sopenharmony_ci	__le32 dcdc_operation_mode;
1878c2ecf20Sopenharmony_ci	__le32 soc_reset_wait_cnt;
1888c2ecf20Sopenharmony_ci	__le32 waiting_time_at_fresh_sleep;
1898c2ecf20Sopenharmony_ci	__le32 max_threshold_to_avoid_sleep;
1908c2ecf20Sopenharmony_ci	u8 beacon_resedue_alg_en;
1918c2ecf20Sopenharmony_ci} __packed;
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci#endif
194