summaryrefslogtreecommitdiff
path: root/core/bmi/src
diff options
context:
space:
mode:
authorKomal Seelam <kseelam@codeaurora.org>2016-02-15 10:31:44 +0530
committerPrakash Dhavali <pdhavali@codeaurora.org>2016-03-23 13:45:08 -0700
commitd910649caa2c5cf91f0269ffecf76ffb7c0fc3e1 (patch)
tree2e331e74b9ecece529ff02587b0edd51b7e4b91f /core/bmi/src
parent02d0934a4a83aee8bd0940f5869c032a194d3ca6 (diff)
qcacld-3.0: Create OL BMI Context in global CDS Context.
Create bmi context in global cds context for BMI operations. Modify HIF BMI API to pass dma command and response Pass BMI DMA Command and Response address to HIF BMI API as arguments instead of using bmi context in HIF. Change-Id: Ifdb51581a33665b1857c63e33b1c26bbd99575eb CRs-Fixed: 967765
Diffstat (limited to 'core/bmi/src')
-rw-r--r--core/bmi/src/bmi.c82
-rw-r--r--core/bmi/src/bmi_1.c24
-rw-r--r--core/bmi/src/bmi_2.c28
-rw-r--r--core/bmi/src/i_bmi.h12
4 files changed, 122 insertions, 24 deletions
diff --git a/core/bmi/src/bmi.c b/core/bmi/src/bmi.c
index c520057265bb..ad625a0cb661 100644
--- a/core/bmi/src/bmi.c
+++ b/core/bmi/src/bmi.c
@@ -128,9 +128,10 @@ void bmi_cleanup(struct ol_softc *scn)
}
-CDF_STATUS bmi_done(struct ol_softc *scn)
+CDF_STATUS bmi_done(struct ol_context *ol_ctx)
{
CDF_STATUS status = CDF_STATUS_SUCCESS;
+ struct ol_softc *scn = ol_ctx->scn;
if (NO_BMI)
return status;
@@ -151,6 +152,8 @@ bmi_get_target_info(struct bmi_target_info *targ_info,
uint8_t *bmi_cmd_buff = info->bmi_cmd_buff;
uint8_t *bmi_rsp_buff = info->bmi_rsp_buff;
uint32_t cid, length;
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
if (info->bmi_done) {
BMI_ERR("BMI Phase is Already Done");
@@ -166,7 +169,7 @@ bmi_get_target_info(struct bmi_target_info *targ_info,
cdf_mem_copy(bmi_cmd_buff, &cid, sizeof(cid));
length = sizeof(struct bmi_target_info);
- status = hif_exchange_bmi_msg(scn, bmi_cmd_buff, sizeof(cid),
+ status = hif_exchange_bmi_msg(scn, cmd, rsp, bmi_cmd_buff, sizeof(cid),
(uint8_t *)bmi_rsp_buff, &length,
BMI_EXCHANGE_TIMEOUT_MS);
if (status) {
@@ -190,11 +193,12 @@ static inline uint32_t bmi_get_test_addr(void)
}
#endif
-CDF_STATUS bmi_download_firmware(struct ol_softc *scn)
+CDF_STATUS bmi_download_firmware(struct ol_context *ol_ctx)
{
uint8_t data[10], out[10];
uint32_t address;
int32_t ret;
+ struct ol_softc *scn = ol_ctx->scn;
if (NO_BMI)
return CDF_STATUS_SUCCESS; /* no BMI for Q6 bring up */
@@ -233,6 +237,8 @@ bmi_read_soc_register(uint32_t address, uint32_t *param, struct ol_softc *scn)
struct bmi_info *info = hif_get_bmi_ctx(scn);
uint8_t *bmi_cmd_buff = info->bmi_cmd_buff;
uint8_t *bmi_rsp_buff = info->bmi_rsp_buff;
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
bmi_assert(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address)));
cdf_mem_set(bmi_cmd_buff, 0, sizeof(cid) + sizeof(address));
@@ -254,7 +260,7 @@ bmi_read_soc_register(uint32_t address, uint32_t *param, struct ol_softc *scn)
cdf_mem_copy(&(bmi_cmd_buff[offset]), &address, sizeof(address));
offset += sizeof(address);
param_len = sizeof(*param);
- status = hif_exchange_bmi_msg(scn, bmi_cmd_buff, offset,
+ status = hif_exchange_bmi_msg(scn, cmd, rsp, bmi_cmd_buff, offset,
bmi_rsp_buff, &param_len, BMI_EXCHANGE_TIMEOUT_MS);
if (status) {
BMI_DBG("Unable to read from the device; status:%d", status);
@@ -275,6 +281,9 @@ bmi_write_soc_register(uint32_t address, uint32_t param, struct ol_softc *scn)
struct bmi_info *info = hif_get_bmi_ctx(scn);
uint8_t *bmi_cmd_buff = info->bmi_cmd_buff;
uint32_t size = sizeof(cid) + sizeof(address) + sizeof(param);
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
+
bmi_assert(BMI_COMMAND_FITS(size));
cdf_mem_set(bmi_cmd_buff, 0, size);
@@ -295,7 +304,7 @@ bmi_write_soc_register(uint32_t address, uint32_t param, struct ol_softc *scn)
offset += sizeof(address);
cdf_mem_copy(&(bmi_cmd_buff[offset]), &param, sizeof(param));
offset += sizeof(param);
- status = hif_exchange_bmi_msg(scn, bmi_cmd_buff, offset,
+ status = hif_exchange_bmi_msg(scn, cmd, rsp, bmi_cmd_buff, offset,
NULL, NULL, 0);
if (status) {
BMI_ERR("Unable to write to the device: status:%d", status);
@@ -316,6 +325,8 @@ bmilz_data(uint8_t *buffer, uint32_t length, struct ol_softc *scn)
const uint32_t header = sizeof(cid) + sizeof(length);
struct bmi_info *info = hif_get_bmi_ctx(scn);
uint8_t *bmi_cmd_buff = info->bmi_cmd_buff;
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
bmi_assert(BMI_COMMAND_FITS(BMI_DATASZ_MAX + header));
cdf_mem_set(bmi_cmd_buff, 0, BMI_DATASZ_MAX + header);
@@ -342,8 +353,9 @@ bmilz_data(uint8_t *buffer, uint32_t length, struct ol_softc *scn)
cdf_mem_copy(&(bmi_cmd_buff[offset]),
&buffer[length - remaining], txlen);
offset += txlen;
- status = hif_exchange_bmi_msg(scn, bmi_cmd_buff, offset,
- NULL, NULL, 0);
+ status = hif_exchange_bmi_msg(scn, cmd, rsp,
+ bmi_cmd_buff, offset,
+ NULL, NULL, 0);
if (status) {
BMI_ERR("Failed to write to the device: status:%d",
status);
@@ -370,6 +382,8 @@ bmi_sign_stream_start(uint32_t address,
struct bmi_info *info = hif_get_bmi_ctx(scn);
uint8_t *bmi_cmd_buff = info->bmi_cmd_buff;
uint32_t remaining, txlen;
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
bmi_assert(BMI_COMMAND_FITS(BMI_DATASZ_MAX + header));
cdf_mem_set(bmi_cmd_buff, 0, BMI_DATASZ_MAX + header);
@@ -407,9 +421,9 @@ bmi_sign_stream_start(uint32_t address,
offset += sizeof(txlen);
cdf_mem_copy(&(bmi_cmd_buff[offset]), src, txlen);
offset += txlen;
- status = hif_exchange_bmi_msg(scn,
- bmi_cmd_buff, offset,
- NULL, NULL, BMI_EXCHANGE_TIMEOUT_MS);
+ status = hif_exchange_bmi_msg(scn, cmd, rsp,
+ bmi_cmd_buff, offset, NULL,
+ NULL, BMI_EXCHANGE_TIMEOUT_MS);
if (status) {
BMI_ERR("Unable to write to the device: status:%d",
status);
@@ -430,6 +444,8 @@ bmilz_stream_start(uint32_t address, struct ol_softc *scn)
uint32_t offset;
struct bmi_info *info = hif_get_bmi_ctx(scn);
uint8_t *bmi_cmd_buff = info->bmi_cmd_buff;
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
bmi_assert(BMI_COMMAND_FITS(sizeof(cid) + sizeof(address)));
cdf_mem_set(bmi_cmd_buff, 0, sizeof(cid) + sizeof(address));
@@ -447,7 +463,7 @@ bmilz_stream_start(uint32_t address, struct ol_softc *scn)
offset += sizeof(cid);
cdf_mem_copy(&(bmi_cmd_buff[offset]), &address, sizeof(address));
offset += sizeof(address);
- status = hif_exchange_bmi_msg(scn, bmi_cmd_buff, offset,
+ status = hif_exchange_bmi_msg(scn, cmd, rsp, bmi_cmd_buff, offset,
NULL, NULL, 0);
if (status) {
BMI_ERR("Unable to Start LZ Stream to the device status:%d",
@@ -494,3 +510,47 @@ end:
return status;
}
+/**
+ * ol_cds_init() - API to initialize global CDS OL Context
+ * @cdf_dev: CDF Device
+ * @hif_ctx: HIF Context
+ *
+ * Return: Success/Failure
+ */
+CDF_STATUS ol_cds_init(cdf_device_t cdf_dev, void *hif_ctx)
+{
+ struct ol_context *ol_info;
+ CDF_STATUS status = CDF_STATUS_SUCCESS;
+
+ if (NO_BMI)
+ return CDF_STATUS_SUCCESS; /* no BMI for Q6 bring up */
+
+ status = cds_alloc_context(cds_get_global_context(), CDF_MODULE_ID_BMI,
+ (void **)&ol_info, sizeof(*ol_info));
+
+ if (status != CDF_STATUS_SUCCESS) {
+ BMI_ERR("%s: CDS Allocation failed for ol_bmi context",
+ __func__);
+ return status;
+ }
+
+ ol_info->cdf_dev = cdf_dev;
+ ol_info->scn = hif_ctx;
+
+ return status;
+}
+
+/**
+ * ol_cds_free() - API to free the global CDS OL Context
+ *
+ * Return: void
+ */
+void ol_cds_free(void)
+{
+ struct ol_context *ol_info = cds_get_context(CDF_MODULE_ID_BMI);
+
+ if (NO_BMI)
+ return;
+
+ cds_free_context(cds_get_global_context(), CDF_MODULE_ID_BMI, ol_info);
+}
diff --git a/core/bmi/src/bmi_1.c b/core/bmi/src/bmi_1.c
index 1936623c5d14..d2293338051d 100644
--- a/core/bmi/src/bmi_1.c
+++ b/core/bmi/src/bmi_1.c
@@ -42,6 +42,8 @@ bmi_read_memory(uint32_t address,
uint8_t *bmi_cmd_buff = info->bmi_cmd_buff;
uint8_t *bmi_rsp_buff = info->bmi_rsp_buff;
uint32_t align;
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
if (info->bmi_done) {
BMI_DBG("command disallowed");
@@ -80,8 +82,9 @@ bmi_read_memory(uint32_t address,
offset += sizeof(length);
/* note we reuse the same buffer to receive on */
- status = hif_exchange_bmi_msg(scn, bmi_cmd_buff, offset,
- bmi_rsp_buff, &rxlen, BMI_EXCHANGE_TIMEOUT_MS);
+ status = hif_exchange_bmi_msg(scn, cmd, rsp, bmi_cmd_buff,
+ offset, bmi_rsp_buff, &rxlen,
+ BMI_EXCHANGE_TIMEOUT_MS);
if (status) {
BMI_ERR("Unable to read from the device");
return CDF_STATUS_E_FAILURE;
@@ -115,6 +118,8 @@ bmi_write_memory(uint32_t address,
uint8_t *src;
struct bmi_info *info = hif_get_bmi_ctx(scn);
uint8_t *bmi_cmd_buff = info->bmi_cmd_buff;
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
if (info->bmi_done) {
BMI_ERR("Command disallowed");
@@ -158,8 +163,9 @@ bmi_write_memory(uint32_t address,
offset += sizeof(txlen);
cdf_mem_copy(&(bmi_cmd_buff[offset]), src, txlen);
offset += txlen;
- status = hif_exchange_bmi_msg(scn, bmi_cmd_buff, offset,
- NULL, NULL, BMI_EXCHANGE_TIMEOUT_MS);
+ status = hif_exchange_bmi_msg(scn, cmd, rsp, bmi_cmd_buff,
+ offset, NULL, NULL,
+ BMI_EXCHANGE_TIMEOUT_MS);
if (status) {
BMI_ERR("Unable to write to the device; status:%d",
status);
@@ -185,6 +191,8 @@ bmi_execute(uint32_t address, A_UINT32 *param, struct ol_softc *scn)
uint8_t *bmi_cmd_buff = info->bmi_cmd_buff;
uint8_t *bmi_rsp_buff = info->bmi_rsp_buff;
uint32_t size = sizeof(cid) + sizeof(address) + sizeof(param);
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
if (info->bmi_done) {
BMI_ERR("Command disallowed");
@@ -214,7 +222,7 @@ bmi_execute(uint32_t address, A_UINT32 *param, struct ol_softc *scn)
cdf_mem_copy(&(bmi_cmd_buff[offset]), param, sizeof(*param));
offset += sizeof(*param);
param_len = sizeof(*param);
- status = hif_exchange_bmi_msg(scn, bmi_cmd_buff, offset,
+ status = hif_exchange_bmi_msg(scn, cmd, rsp, bmi_cmd_buff, offset,
bmi_rsp_buff, &param_len, 0);
if (status) {
BMI_ERR("Unable to read from the device status:%d", status);
@@ -278,6 +286,7 @@ CDF_STATUS bmi_done_local(struct ol_softc *scn)
uint32_t cid;
struct bmi_info *info;
cdf_device_t cdf_dev = cds_get_context(CDF_MODULE_ID_CDF_DEVICE);
+ cdf_dma_addr_t cmd, rsp;
if (!scn) {
BMI_ERR("Invalid scn context");
@@ -296,6 +305,9 @@ CDF_STATUS bmi_done_local(struct ol_softc *scn)
return CDF_STATUS_E_PERM;
}
+ cmd = info->bmi_cmd_da;
+ rsp = info->bmi_rsp_da;
+
BMI_DBG("BMI Done: Enter (device: 0x%p)", scn);
info->bmi_done = true;
@@ -309,7 +321,7 @@ CDF_STATUS bmi_done_local(struct ol_softc *scn)
cdf_mem_copy(info->bmi_cmd_buff, &cid, sizeof(cid));
- status = hif_exchange_bmi_msg(scn, info->bmi_cmd_buff,
+ status = hif_exchange_bmi_msg(scn, cmd, rsp, info->bmi_cmd_buff,
sizeof(cid), NULL, NULL, 0);
if (status) {
BMI_ERR("Failed to write to the device; status:%d", status);
diff --git a/core/bmi/src/bmi_2.c b/core/bmi/src/bmi_2.c
index 16fdf7223cc5..a3a6d00d607c 100644
--- a/core/bmi/src/bmi_2.c
+++ b/core/bmi/src/bmi_2.c
@@ -43,6 +43,8 @@ bmi_no_command(struct ol_softc *scn)
struct bmi_info *info = hif_get_bmi_ctx(scn);
uint8_t *bmi_cmd_buff = info->bmi_cmd_buff;
uint8_t *bmi_rsp_buff = info->bmi_rsp_buff;
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
if (info->bmi_done) {
BMI_ERR("Command disallowed: BMI DONE ALREADY");
@@ -58,7 +60,7 @@ bmi_no_command(struct ol_softc *scn)
cdf_mem_copy(bmi_cmd_buff, &cid, sizeof(cid));
length = sizeof(ret);
- status = hif_exchange_bmi_msg(scn, bmi_cmd_buff, sizeof(cid),
+ status = hif_exchange_bmi_msg(scn, cmd, rsp, bmi_cmd_buff, sizeof(cid),
bmi_rsp_buff, &length, BMI_EXCHANGE_TIMEOUT_MS);
if (status) {
@@ -85,6 +87,8 @@ bmi_done_local(struct ol_softc *scn)
uint8_t *bmi_cmd_buff = info->bmi_cmd_buff;
uint8_t *bmi_rsp_buff = info->bmi_rsp_buff;
cdf_device_t cdf_dev = cds_get_context(CDF_MODULE_ID_CDF_DEVICE);
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
if (info->bmi_done) {
BMI_ERR("Command disallowed");
@@ -106,7 +110,7 @@ bmi_done_local(struct ol_softc *scn)
cdf_mem_copy(bmi_cmd_buff, &cid, sizeof(cid));
length = sizeof(ret);
- status = hif_exchange_bmi_msg(scn, bmi_cmd_buff, sizeof(cid),
+ status = hif_exchange_bmi_msg(scn, cmd, rsp, bmi_cmd_buff, sizeof(cid),
bmi_rsp_buff, &length, BMI_EXCHANGE_TIMEOUT_MS);
if (status) {
@@ -155,6 +159,8 @@ bmi_write_memory(uint32_t address,
struct bmi_info *info = hif_get_bmi_ctx(scn);
uint8_t *bmi_cmd_buff = info->bmi_cmd_buff;
uint8_t *bmi_rsp_buff = info->bmi_rsp_buff;
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
if (info->bmi_done) {
BMI_ERR("Command disallowed");
@@ -196,8 +202,9 @@ bmi_write_memory(uint32_t address,
offset += sizeof(txlen);
cdf_mem_copy(&(bmi_cmd_buff[offset]), src, txlen);
offset += txlen;
- status = hif_exchange_bmi_msg(scn, bmi_cmd_buff, offset,
- bmi_rsp_buff, &rsp_len, BMI_EXCHANGE_TIMEOUT_MS);
+ status = hif_exchange_bmi_msg(scn, cmd, rsp, bmi_cmd_buff,
+ offset, bmi_rsp_buff, &rsp_len,
+ BMI_EXCHANGE_TIMEOUT_MS);
if (status) {
BMI_ERR("BMI Write Memory Failed status:%d", status);
return CDF_STATUS_E_FAILURE;
@@ -227,6 +234,8 @@ bmi_read_memory(uint32_t address, uint8_t *buffer,
/* note we reuse the same buffer to receive on */
uint8_t *bmi_rsp_buff = info->bmi_rsp_buff;
uint32_t size = sizeof(cid) + sizeof(address) + sizeof(length);
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
if (info->bmi_done) {
BMI_ERR("Command disallowed");
@@ -259,7 +268,7 @@ bmi_read_memory(uint32_t address, uint8_t *buffer,
total_len = rxlen + rsp_len;
- status = hif_exchange_bmi_msg(scn,
+ status = hif_exchange_bmi_msg(scn, cmd, rsp,
bmi_cmd_buff,
offset,
bmi_rsp_buff,
@@ -297,6 +306,8 @@ bmi_execute(uint32_t address, uint32_t *param,
struct bmi_info *info = hif_get_bmi_ctx(scn);
uint8_t *bmi_cmd_buff = info->bmi_cmd_buff;
uint8_t *bmi_rsp_buff = info->bmi_rsp_buff;
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
if (info->bmi_done) {
BMI_ERR("Command disallowed");
@@ -313,7 +324,7 @@ bmi_execute(uint32_t address, uint32_t *param,
cdf_mem_copy(bmi_cmd_buff, &cid, sizeof(cid));
length = sizeof(ret);
- status = hif_exchange_bmi_msg(scn, bmi_cmd_buff, sizeof(cid),
+ status = hif_exchange_bmi_msg(scn, cmd, rsp, bmi_cmd_buff, sizeof(cid),
bmi_rsp_buff, &length, BMI_EXCHANGE_TIMEOUT_MS);
if (status) {
@@ -342,6 +353,9 @@ bmi_load_image(dma_addr_t address,
struct bmi_info *info = hif_get_bmi_ctx(scn);
uint8_t *bmi_cmd_buff = info->bmi_cmd_buff;
uint8_t *bmi_rsp_buff = info->bmi_rsp_buff;
+ cdf_dma_addr_t cmd = info->bmi_cmd_da;
+ cdf_dma_addr_t rsp = info->bmi_rsp_da;
+
uint32_t addr_h, addr_l;
if (info->bmi_done) {
@@ -375,7 +389,7 @@ bmi_load_image(dma_addr_t address,
offset += sizeof(size);
length = sizeof(ret);
- status = hif_exchange_bmi_msg(scn, bmi_cmd_buff, offset,
+ status = hif_exchange_bmi_msg(scn, cmd, rsp, bmi_cmd_buff, offset,
bmi_rsp_buff, &length, BMI_EXCHANGE_TIMEOUT_MS);
if (status) {
diff --git a/core/bmi/src/i_bmi.h b/core/bmi/src/i_bmi.h
index 7e9d984e33e8..d6f82352027b 100644
--- a/core/bmi/src/i_bmi.h
+++ b/core/bmi/src/i_bmi.h
@@ -121,6 +121,18 @@ typedef enum _ATH_BIN_FILE {
#define NO_BMI 0
#endif
+/**
+ * struct ol_context - Structure to hold OL context
+ * @cdf_dev: CDF Device
+ * @scn: HIF Context
+ *
+ * Structure to hold all ol BMI/Ramdump info
+ */
+struct ol_context {
+ cdf_device_t cdf_dev;
+ struct ol_softc *scn;
+};
+
CDF_STATUS bmi_execute(uint32_t address, uint32_t *param,
struct ol_softc *scn);
CDF_STATUS bmi_init(struct ol_softc *scn);