blob: 087db4fe03fecc88608c2114ec7211ee894c70a9 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Govind Singh0a60e552016-01-13 17:44:48 +05302 * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27/* ===================================================================
28 * Internal BMI Header File
29 */
30
31#ifndef _I_BMI_H_
32#define _I_BMI_H_
33
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080034#include "hif.h"
35#include "bmi_msg.h"
36#include "bmi.h"
37#include "ol_fw.h"
Yuanyuan Liueaa6b6e2016-04-26 12:40:26 -070038#include "pld_common.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080039
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040/*
41 * Note that not all the register locations are accessible.
42 * A list of accessible target registers are specified with
43 * their start and end addresses in a table for given target
44 * version. We should NOT access other locations as either
45 * they are invalid locations or host does not have read
46 * access to it or the value of the particular register
47 * read might change
48 */
49#define REGISTER_LOCATION 0x00000800
50
51#define DRAM_LOCATION 0x00400000
52#define DRAM_SIZE 0x000a8000
53/* The local base addr is used to read the target dump using pcie I/O reads */
54#define DRAM_LOCAL_BASE_ADDR (0x100000)
55
56#define IRAM_LOCATION 0x00980000
57#define IRAM_SIZE 0x00038000
58
59#define AXI_LOCATION 0x000a0000
60#define AXI_SIZE 0x00018000
61
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080062#define TOTAL_DUMP_SIZE 0x00200000
63#define PCIE_READ_LIMIT 0x00005000
64
65#define SHA256_DIGEST_SIZE 32
66
67/* BMI LOGGING WRAPPERS */
68
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053069#define BMI_LOG(level, args...) QDF_TRACE(QDF_MODULE_ID_BMI, \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070 level, ##args)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053071#define BMI_ERR(args ...) BMI_LOG(QDF_TRACE_LEVEL_ERROR, args)
72#define BMI_DBG(args ...) BMI_LOG(QDF_TRACE_LEVEL_DEBUG, args)
73#define BMI_WARN(args ...) BMI_LOG(QDF_TRACE_LEVEL_WARN, args)
74#define BMI_INFO(args ...) BMI_LOG(QDF_TRACE_LEVEL_INFO, args)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075/* End of BMI Logging Wrappers */
76
77/* BMI Assert Wrappers */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053078#define bmi_assert QDF_BUG
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079/*
80 * Although we had envisioned BMI to run on top of HTC, this is not how the
81 * final implementation ended up. On the Target side, BMI is a part of the BSP
82 * and does not use the HTC protocol nor even DMA -- it is intentionally kept
83 * very simple.
84 */
85
86#define MAX_BMI_CMDBUF_SZ (BMI_DATASZ_MAX + \
87 sizeof(uint32_t) /* cmd */ + \
88 sizeof(uint32_t) /* addr */ + \
89 sizeof(uint32_t)) /* length */
90#define BMI_COMMAND_FITS(sz) ((sz) <= MAX_BMI_CMDBUF_SZ)
91#define BMI_EXCHANGE_TIMEOUT_MS 1000
92
93struct hash_fw {
94 u8 qwlan[SHA256_DIGEST_SIZE];
95 u8 otp[SHA256_DIGEST_SIZE];
96 u8 bdwlan[SHA256_DIGEST_SIZE];
97 u8 utf[SHA256_DIGEST_SIZE];
98};
99
100typedef enum _ATH_BIN_FILE {
101 ATH_OTP_FILE,
102 ATH_FIRMWARE_FILE,
103 ATH_PATCH_FILE,
104 ATH_BOARD_DATA_FILE,
105 ATH_FLASH_FILE,
106 ATH_SETUP_FILE,
107} ATH_BIN_FILE;
108
Houston Hoffman6ccc86a2015-12-16 18:43:34 -0800109#if defined(QCA_WIFI_3_0_ADRASTEA)
110#define NO_BMI 1
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111#else
Houston Hoffman6ccc86a2015-12-16 18:43:34 -0800112#define NO_BMI 0
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113#endif
114
Komal Seelamd9106492016-02-15 10:31:44 +0530115/**
Komal Seelam9ef94582016-02-24 18:14:55 +0530116 * struct bmi_info - Structure to hold BMI Specific information
117 * @bmi_cmd_buff - BMI Command Buffer
118 * @bmi_rsp_buff - BMI Response Buffer
119 * @bmi_cmd_da - BMI Command Physical address
120 * @bmi_rsp_da - BMI Response Physical address
121 * @bmi_done - Flag to check if BMI Phase is complete
122 * @fw_files - FW files
123 *
124 */
125struct bmi_info {
126 uint8_t *bmi_cmd_buff;
127 uint8_t *bmi_rsp_buff;
128 dma_addr_t bmi_cmd_da;
129 dma_addr_t bmi_rsp_da;
130 bool bmi_done;
Yuanyuan Liueaa6b6e2016-04-26 12:40:26 -0700131 struct pld_fw_files fw_files;
Komal Seelam9ef94582016-02-24 18:14:55 +0530132};
133
134/**
Komal Seelamd9106492016-02-15 10:31:44 +0530135 * struct ol_context - Structure to hold OL context
Komal Seelam9ef94582016-02-24 18:14:55 +0530136 * @bmi: BMI info
137 * @cal_in_flash: For Firmware Flash Download
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530138 * @qdf_dev: QDF Device
Komal Seelamd9106492016-02-15 10:31:44 +0530139 * @scn: HIF Context
Yuanyuan Liueaa6b6e2016-04-26 12:40:26 -0700140 * @ramdump_work: Work for Ramdump collection
141 * @fw_indication_work: Work for Fw inciation
Komal Seelam9ef94582016-02-24 18:14:55 +0530142 * @tgt_def: Target Defnition pointer
Komal Seelamd9106492016-02-15 10:31:44 +0530143 *
144 * Structure to hold all ol BMI/Ramdump info
145 */
146struct ol_context {
Komal Seelam9ef94582016-02-24 18:14:55 +0530147 struct bmi_info bmi;
Komal Seelamec702b02016-02-24 18:42:16 +0530148 struct ol_config_info cfg_info;
Komal Seelam9ef94582016-02-24 18:14:55 +0530149 uint8_t *cal_in_flash;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530150 qdf_device_t qdf_dev;
Anurag Chouhandf2b2682016-02-29 14:15:27 +0530151 qdf_work_t ramdump_work;
Yuanyuan Liueaa6b6e2016-04-26 12:40:26 -0700152 qdf_work_t fw_indication_work;
Komal Seelam3d202862016-02-24 18:43:24 +0530153 struct hif_opaque_softc *scn;
Komal Seelam42c16a12016-02-16 18:09:10 +0530154 struct targetdef_t {
155 struct targetdef_s *targetdef;
156 } tgt_def;
Komal Seelamd9106492016-02-15 10:31:44 +0530157};
158
Komal Seelam9ef94582016-02-24 18:14:55 +0530159#define GET_BMI_CONTEXT(ol_ctx) ((struct bmi_info *)ol_ctx)
160
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530161QDF_STATUS bmi_execute(uint32_t address, uint32_t *param,
Komal Seelam5a6e5082016-02-24 17:59:09 +0530162 struct ol_context *ol_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530163QDF_STATUS bmi_init(struct ol_context *ol_ctx);
164QDF_STATUS bmi_no_command(struct ol_context *ol_ctx);
165QDF_STATUS bmi_read_memory(uint32_t address, uint8_t *buffer, uint32_t length,
Komal Seelam5a6e5082016-02-24 17:59:09 +0530166 struct ol_context *ol_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530167QDF_STATUS bmi_write_memory(uint32_t address, uint8_t *buffer, uint32_t length,
Komal Seelam5a6e5082016-02-24 17:59:09 +0530168 struct ol_context *ol_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530169QDF_STATUS bmi_fast_download(uint32_t address, uint8_t *buffer, uint32_t length,
Komal Seelam5a6e5082016-02-24 17:59:09 +0530170 struct ol_context *ol_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530171QDF_STATUS bmi_read_soc_register(uint32_t address,
Komal Seelam5a6e5082016-02-24 17:59:09 +0530172 uint32_t *param, struct ol_context *ol_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530173QDF_STATUS bmi_write_soc_register(uint32_t address, uint32_t param,
Komal Seelam5a6e5082016-02-24 17:59:09 +0530174 struct ol_context *ol_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530175QDF_STATUS bmi_get_target_info(struct bmi_target_info *targ_info,
Komal Seelam08633492016-02-24 18:05:07 +0530176 struct ol_context *ol_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530177QDF_STATUS bmi_firmware_download(struct ol_context *ol_ctx);
178QDF_STATUS bmi_done_local(struct ol_context *ol_ctx);
179QDF_STATUS ol_download_firmware(struct ol_context *ol_ctx);
180QDF_STATUS ol_configure_target(struct ol_context *ol_ctx);
Houston Hoffmanea4c79c2016-04-21 20:20:31 -0700181QDF_STATUS bmi_sign_stream_start(uint32_t address, uint8_t *buffer,
182 uint32_t length, struct ol_context *ol_ctx);
Komal Seelam08633492016-02-24 18:05:07 +0530183void ramdump_work_handler(void *arg);
Yuanyuan Liueaa6b6e2016-04-26 12:40:26 -0700184void fw_indication_work_handler(void *arg);
Komal Seelamec702b02016-02-24 18:42:16 +0530185struct ol_config_info *ol_get_ini_handle(struct ol_context *ol_ctx);
Poddar, Siddarthef1f3022016-05-10 20:10:43 +0530186
187#ifdef HIF_SDIO
188QDF_STATUS hif_reg_based_get_target_info(struct hif_opaque_softc *hif_ctx,
189 struct bmi_target_info *targ_info);
190#endif
191#if defined(HIF_PCI) || defined(SNOC) || defined(HIF_AHB)
192static inline QDF_STATUS
193hif_reg_based_get_target_info(struct hif_opaque_softc *hif_ctx,
194 struct bmi_target_info *targ_info)
195{
196 return QDF_STATUS_SUCCESS;
197}
198#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199#endif