hc
2024-08-12 233ab1bd4c5697f5cdec94e60206e8c6ac609b4c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
 * Copyright (C) 2017 Spreadtrum Communications Inc.
 *
 * Filename : wcn_integrate_platform.h
 * Abstract : This file is a implementation for driver of integrated marlin:
 *                The marlin chip and GNSS chip were integrated with AP chipset.
 *
 * Authors    : yaoguang.chen
 *
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
 
#ifndef __WCN_INTEGRATE_H__
#define __WCN_INTEGRATE_H__
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/file.h>
#include <linux/firmware.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/mfd/syscon.h>
#include <linux/of_gpio.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/proc_fs.h>
#include <linux/platform_device.h>
#include <linux/regulator/consumer.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/unistd.h>
#include <linux/vmalloc.h>
#include <linux/workqueue.h>
 
#include "linux/sipc.h"
#include "linux/sprd_otp.h"
 
#include "wcn_integrate_dev.h"
 
#define REGMAP_UPDATE_BITS_ENABLE 0    /* It can't work well. */
 
#define MDBG_CACHE_FLAG_VALUE    (0xcdcddcdc)
 
#define WCN_AON_CHIP_ID0 0x00E0
#define WCN_AON_CHIP_ID1 0x00E4
#define WCN_AON_PLATFORM_ID0 0x00E8
#define WCN_AON_PLATFORM_ID1 0x00EC
#define WCN_AON_CHIP_ID 0x00FC
#define WCN_AON_VERSION_ID 0x00F8
 
#define PIKE2_CHIP_ID0 0x32000000    /* 2 */
#define PIKE2_CHIP_ID1 0x50696B65    /* Pike */
#define SHARKLE_CHIP_ID0 0x6B4C4500    /* kle */
#define SHARKLE_CHIP_ID1 0x53686172    /* Shar */
#define SHARKL3_CHIP_ID0 0x6B4C3300    /* kl3 */
#define SHARKL3_CHIP_ID1 0x53686172    /* Shar */
 
#define AON_CHIP_ID_AA 0x96360000
#define AON_CHIP_ID_AC 0x96360002
 
struct platform_chip_id {
   u32 aon_chip_id0;
   u32 aon_chip_id1;
   u32 aon_platform_id0;
   u32 aon_platform_id1;
   u32 aon_chip_id;
};
 
enum {
   WCN_PLATFORM_TYPE_SHARKLE,
   WCN_PLATFORM_TYPE_PIKE2,
   WCN_PLATFORM_TYPE_SHARKL3,
   WCN_PLATFORM_TYPE,
};
 
enum wcn_gnss_type {
   WCN_GNSS_TYPE_INVALID,
   WCN_GNSS_TYPE_GL,
   WCN_GNSS_TYPE_BD,
};
 
enum wcn_aon_chip_id {
   WCN_AON_CHIP_ID_INVALID,
   WCN_SHARKLE_CHIP_AA_OR_AB,
   WCN_SHARKLE_CHIP_AC,
   WCN_SHARKLE_CHIP_AD,
   WCN_PIKE2_CHIP,
   WCN_PIKE2_CHIP_AA,
   WCN_PIKE2_CHIP_AB,
};
 
struct wcn_chip_type {
   u32 chipid;
   enum wcn_aon_chip_id chiptype;
};
 
#define WCN_SPECIAL_SHARME_MEM_ADDR    (0x0017c000)
struct wifi_special_share_mem {
   struct wifi_calibration calibration_data;
   u32 efuse[WIFI_EFUSE_BLOCK_COUNT];
   u32 calibration_flag;
};
 
struct marlin_special_share_mem {
   u32 init_status;
   u32 loopcheck_cnt;
};
 
struct gnss_special_share_mem {
   u32 calibration_flag;
   u32 efuse[GNSS_EFUSE_BLOCK_COUNT];
};
 
struct wcn_special_share_mem {
   /* 0x17c000 */
   struct wifi_special_share_mem wifi;
   /* 0x17cf54 */
   struct marlin_special_share_mem marlin;
   /* 0x17cf5c */
   u32 include_gnss;
   /* 0x17cf60 */
   u32 gnss_flag_addr;
   /* 0x17cf64 */
   u32 cp2_sleep_status;
   /* 0x17cf68 */
   u32 sleep_flag_addr;
   /* 0x17cf6c */
   u32 efuse_temper_magic;
   /* 0x17cf70 */
   u32 efuse_temper_val;
   /* 0x17cf74 */
   struct gnss_special_share_mem gnss;
};
 
typedef int (*marlin_reset_callback) (void *para);
 
extern struct platform_chip_id g_platform_chip_id;
extern char functionmask[8];
extern struct wcn_special_share_mem *s_wssm_phy_offset_p;
 
int wcn_write_data_to_phy_addr(phys_addr_t phy_addr,
                  void *src_data, u32 size);
int wcn_read_data_from_phy_addr(phys_addr_t phy_addr,
               void *tar_data, u32 size);
void *wcn_mem_ram_vmap_nocache(phys_addr_t start, size_t size,
                  unsigned int *count);
void wcn_mem_ram_unmap(const void *mem, unsigned int count);
u32 wcn_platform_chip_id(void);
u32 wcn_platform_chip_type(void);
u32 wcn_get_cp2_comm_rx_count(void);
phys_addr_t wcn_get_btwf_base_addr(void);
phys_addr_t wcn_get_btwf_sleep_addr(void);
phys_addr_t wcn_get_btwf_init_status_addr(void);
int wcn_get_btwf_power_status(void);
void wcn_regmap_read(struct regmap *cur_regmap,
               u32 reg,
               unsigned int *val);
void wcn_regmap_raw_write_bit(struct regmap *cur_regmap,
                    u32 reg,
                    unsigned int val);
struct regmap *wcn_get_btwf_regmap(u32 regmap_type);
struct regmap *wcn_get_gnss_regmap(u32 regmap_type);
phys_addr_t wcn_get_gnss_base_addr(void);
bool wcn_get_download_status(void);
void wcn_set_download_status(bool status);
u32 gnss_get_boot_status(void);
void gnss_set_boot_status(u32 status);
int marlin_get_module_status(void);
int wcn_get_module_status_changed(void);
void wcn_set_module_status_changed(bool status);
int marlin_reset_register_notify(void *callback_func, void *para);
int marlin_reset_unregister_notify(void);
void wcn_set_module_state(bool status);
 
int wcn_send_force_sleep_cmd(struct wcn_device *wcn_dev);
u32 wcn_get_sleep_status(struct wcn_device *wcn_dev, int force_sleep);
void wcn_power_domain_set(struct wcn_device *wcn_dev, u32 set_type);
void wcn_xtl_auto_sel(bool enable);
int wcn_power_enable_sys_domain(bool enable);
void wcn_sys_soft_reset(void);
void wcn_sys_ctrl_26m(bool enable);
void wcn_clock_ctrl(bool enable);
void wcn_sys_soft_release(void);
void wcn_sys_deep_sleep_en(void);
void wcn_power_set_vddcon(u32 value);
int wcn_power_enable_vddcon(bool enable);
void wcn_power_set_vddwifipa(u32 value);
int wcn_marlin_power_enable_vddwifipa(bool enable);
u32 wcn_parse_platform_chip_id(struct wcn_device *wcn_dev);
void mdbg_hold_cpu(void);
enum wcn_aon_chip_id wcn_get_aon_chip_id(void);
#endif