From 8f906946fe473edbbaee937e2a8b5154cd76151b Mon Sep 17 00:00:00 2001 From: Lina Iyer Date: Wed, 1 Feb 2017 13:34:54 -0700 Subject: [PATCH] drivers: qcom: cmd-db: Report if command DB is initialized as standalone The command DB may be initialized outside the AOP, indicated by the reserved bit 0. Export this information through a function. Change-Id: I7b8c685cc03d919c5adb1b91134078bd96599bbd Signed-off-by: Lina Iyer --- drivers/soc/qcom/cmd-db.c | 14 ++++++++++++++ include/soc/qcom/cmd-db.h | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c index 345c4b70a6f3..344ab1de615d 100644 --- a/drivers/soc/qcom/cmd-db.c +++ b/drivers/soc/qcom/cmd-db.c @@ -16,6 +16,7 @@ #define MAX_SLV_ID 8 #define SLAVE_ID_MASK 0x7 #define SLAVE_ID_SHIFT 16 +#define CMD_DB_STANDALONE_MASK BIT(0) /** * struct entry_header: header for each entry in cmddb @@ -237,6 +238,16 @@ enum cmd_db_hw_type cmd_db_read_slave_id(const char *id) } EXPORT_SYMBOL(cmd_db_read_slave_id); +bool cmd_db_is_standalone(void) +{ + int ret = cmd_db_ready(); + u32 standalone = le32_to_cpu(cmd_db_header->reserved) & + CMD_DB_STANDALONE_MASK; + + return !ret && standalone; +} +EXPORT_SYMBOL(cmd_db_is_standalone); + static int cmd_db_dev_probe(struct platform_device *pdev) { struct reserved_mem *rmem; @@ -260,6 +271,9 @@ static int cmd_db_dev_probe(struct platform_device *pdev) return -EINVAL; } + if (cmd_db_is_standalone()) + pr_info("Command DB is initialized in standalone mode.\n"); + return 0; } diff --git a/include/soc/qcom/cmd-db.h b/include/soc/qcom/cmd-db.h index c45a6b918200..308c66dc5e61 100644 --- a/include/soc/qcom/cmd-db.h +++ b/include/soc/qcom/cmd-db.h @@ -23,6 +23,8 @@ const void *cmd_db_read_aux_data(const char *resource_id, size_t *len); enum cmd_db_hw_type cmd_db_read_slave_id(const char *resource_id); int cmd_db_ready(void); + +bool cmd_db_is_standalone(void); #else static inline u32 cmd_db_read_addr(const char *resource_id) { return 0; } @@ -35,5 +37,8 @@ static inline enum cmd_db_hw_type cmd_db_read_slave_id(const char *resource_id) static inline int cmd_db_ready(void) { return -ENODEV; } + +static inline bool cmd_db_is_standalone(void) +{ return false; } #endif /* CONFIG_QCOM_COMMAND_DB */ #endif /* __QCOM_COMMAND_DB_H__ */