qcacmn: Call PLD APIs of athdiag read/write when bus type is SNOC

Call PLD APIs of athdiag read/write if current bus type is SNOC.

CRs-Fixed: 1061835
Change-Id: I992a29027e36c98bac429f2402e93462195bd76c
This commit is contained in:
Yuanyuan Liu 2016-08-23 16:51:36 -07:00 • committed by qcabuildsw
commit 3aa7fed319
2 changed files with 46 additions and 0 deletions

View file

@ -32,6 +32,7 @@
#include <linux/proc_fs.h> /* Necessary because we use the proc fs */
#include <asm/uaccess.h> /* for copy_from_user */
#include "hif.h"
#include "hif_main.h"
#if defined(HIF_USB)
#include "if_usb.h"
#endif
@ -39,6 +40,7 @@
#include "if_sdio.h"
#endif
#include "hif_debug.h"
#include "pld_common.h"
#define PROCFS_NAME "athdiagpfs"
#define PROCFS_DIR "cld"
@ -63,6 +65,8 @@ static ssize_t ath_procfs_diag_read(struct file *file, char __user *buf,
hif_handle_t hif_hdl;
int rv;
uint8_t *read_buffer = NULL;
struct hif_softc *scn;
uint32_t offset = 0, memtype = 0;
read_buffer = qdf_mem_malloc(count);
if (NULL == read_buffer) {
@ -74,6 +78,18 @@ static ssize_t ath_procfs_diag_read(struct file *file, char __user *buf,
HIF_DBG("rd buff 0x%p cnt %zu offset 0x%x buf 0x%p",
read_buffer, count, (int)*pos, buf);
scn = HIF_GET_SOFTC(hif_hdl);
if (scn->bus_type == QDF_BUS_TYPE_SNOC) {
memtype = ((uint32_t)(*pos) & 0xff000000) >> 24;
offset = (uint32_t)(*pos) & 0xffffff;
HIF_TRACE("%s: offset 0x%x memtype 0x%x, datalen %zu\n",
__func__, offset, memtype, count);
rv = pld_athdiag_read(scn->qdf_dev->dev,
offset, memtype, count,
(uint8_t *)read_buffer);
goto out;
}
if ((count == 4) && ((((uint32_t) (*pos)) & 3) == 0)) {
/* reading a word? */
rv = hif_diag_read_access(hif_hdl, (uint32_t)(*pos),
@ -83,6 +99,8 @@ static ssize_t ath_procfs_diag_read(struct file *file, char __user *buf,
(uint8_t *)read_buffer, count);
}
out:
if (copy_to_user(buf, read_buffer, count)) {
qdf_mem_free(read_buffer);
HIF_ERROR("%s: copy_to_user error in /proc/%s",
@ -105,6 +123,8 @@ static ssize_t ath_procfs_diag_write(struct file *file,
hif_handle_t hif_hdl;
int rv;
uint8_t *write_buffer = NULL;
struct hif_softc *scn;
uint32_t offset = 0, memtype = 0;
write_buffer = qdf_mem_malloc(count);
if (NULL == write_buffer) {
@ -123,6 +143,18 @@ static ssize_t ath_procfs_diag_write(struct file *file,
write_buffer, buf, count,
(int)*pos, *((uint32_t *) write_buffer));
scn = HIF_GET_SOFTC(hif_hdl);
if (scn->bus_type == QDF_BUS_TYPE_SNOC) {
memtype = ((uint32_t)(*pos) & 0xff000000) >> 24;
offset = (uint32_t)(*pos) & 0xffffff;
HIF_TRACE("%s: offset 0x%x memtype 0x%x, datalen %zu\n",
__func__, offset, memtype, count);
rv = pld_athdiag_write(scn->qdf_dev->dev,
offset, memtype, count,
(uint8_t *)write_buffer);
goto out;
}
if ((count == 4) && ((((uint32_t) (*pos)) & 3) == 0)) {
/* reading a word? */
uint32_t value = *((uint32_t *)write_buffer);
@ -132,6 +164,8 @@ static ssize_t ath_procfs_diag_write(struct file *file,
(uint8_t *)write_buffer, count);
}
out:
qdf_mem_free(write_buffer);
if (rv == 0) {
return count;

View file

@ -210,6 +210,18 @@ static inline void pld_runtime_exit(struct device *dev)
{
return;
}
static inline int pld_athdiag_read(struct device *dev,
uint32_t offset, uint32_t memtype,
uint32_t datalen, uint8_t *output)
{
return 0;
}
static inline int pld_athdiag_write(struct device *dev,
uint32_t offset, uint32_t memtype,
uint32_t datalen, uint8_t *input)
{
return 0;
}
#endif
#endif