From 303f09a9d10e8219705025252b27556f1263048d Mon Sep 17 00:00:00 2001 From: mahj8 Date: Wed, 9 Dec 2020 13:57:27 +0800 Subject: [PATCH] kernel: export some api symbol of pmic vote Export some pmic-voter interfaces for dlkm usage as well as create access functions that are exported for dlkm to manipulate the struct. charging DLKM need some api of pmic vote, but pmic_voter.o is included by both qpnp-smb5-main.ko and qcom-qpnp-qg.ko, KMI don't allow double export one function in two DLKM modules. Change-Id: I56f96b663d9ee2228d91bd2efc6977a13f270de4 Signed-off-by: mahj8 Reviewed-on: https://gerrit.mot.com/1822930 Reviewed-by: Huosheng Liao SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Haijian Ma Submit-Approved: Jira Key --- drivers/power/supply/qcom/Makefile | 2 +- drivers/power/supply/qcom/mmi-pmic-voter.c | 60 ++++++++++++++++++++++ include/linux/mmi-pmic-voter.h | 19 +++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 drivers/power/supply/qcom/mmi-pmic-voter.c create mode 100644 include/linux/mmi-pmic-voter.h diff --git a/drivers/power/supply/qcom/Makefile b/drivers/power/supply/qcom/Makefile index f08dd44c9dba..8f632f9d3ca0 100644 --- a/drivers/power/supply/qcom/Makefile +++ b/drivers/power/supply/qcom/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_QPNP_SMB5) += qpnp-smb5-main.o -qpnp-smb5-main-y += step-chg-jeita.o battery.o qpnp-smb5.o smb5-lib.o pmic-voter.o storm-watch.o schgm-flash.o battery-profile-loader.o smb5-iio.o +qpnp-smb5-main-y += step-chg-jeita.o battery.o qpnp-smb5.o smb5-lib.o pmic-voter.o mmi-pmic-voter.o storm-watch.o schgm-flash.o battery-profile-loader.o smb5-iio.o obj-$(CONFIG_QPNP_QG) += qcom-qpnp-qg.o qcom-qpnp-qg-y += qpnp-qg.o battery-profile-loader.o pmic-voter.o qg-util.o qg-soc.o qg-sdam.o qg-battery-profile.o qg-profile-lib.o fg-alg.o obj-$(CONFIG_SMB1398_CHARGER) += qcom-smb1398-charger.o diff --git a/drivers/power/supply/qcom/mmi-pmic-voter.c b/drivers/power/supply/qcom/mmi-pmic-voter.c new file mode 100644 index 000000000000..cac27fa884f4 --- /dev/null +++ b/drivers/power/supply/qcom/mmi-pmic-voter.c @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2015-2017, 2019-2020, The Linux Foundation. All rights reserved. + */ + +#include +#include +#include + +int mmi_get_effective_result(struct votable *votable) +{ + if(votable) + return get_effective_result(votable); + + return -EINVAL; +} +EXPORT_SYMBOL(mmi_get_effective_result); + +int mmi_vote(struct votable *votable, const char *client_str, bool enabled, int val) +{ + if(votable) + return vote(votable, client_str, enabled, val); + + return -EINVAL; +} +EXPORT_SYMBOL(mmi_vote); + +int mmi_rerun_election(struct votable *votable) +{ + if(votable) + return rerun_election(votable); + + return -EINVAL; +} +EXPORT_SYMBOL(mmi_rerun_election); + +struct votable *mmi_find_votable(const char *name) +{ + return find_votable(name); +} +EXPORT_SYMBOL(mmi_find_votable); + +int mmi_pmic_vote_force_val_set(struct votable *votable, u32 val) +{ + return pmic_vote_force_val_set(votable, val); +} +EXPORT_SYMBOL(mmi_pmic_vote_force_val_set); + +int mmi_pmic_vote_force_active_get(struct votable *votable, u64 *val) +{ + return pmic_vote_force_active_get(votable, val); +} +EXPORT_SYMBOL(mmi_pmic_vote_force_active_get); + +int mmi_pmic_vote_force_active_set(struct votable *votable, u64 val) +{ + return pmic_vote_force_active_set(votable, val); +} +EXPORT_SYMBOL(mmi_pmic_vote_force_active_set); + diff --git a/include/linux/mmi-pmic-voter.h b/include/linux/mmi-pmic-voter.h new file mode 100644 index 000000000000..2879839600cc --- /dev/null +++ b/include/linux/mmi-pmic-voter.h @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2015-2017, 2019-2020, The Linux Foundation. All rights reserved. + */ + + #ifndef __MMI_PMIC_VOTER_H +#define __MMI_PMIC_VOTER_H + +#include + +int mmi_get_effective_result(struct votable *votable); +int mmi_vote(struct votable *votable, const char *client_str, bool enabled, int val); +int mmi_rerun_election(struct votable *votable); +struct votable *mmi_find_votable(const char *name); +int mmi_pmic_vote_force_val_set(struct votable *votable, u32 val); +int mmi_pmic_vote_force_active_get(struct votable *votable, u64 *val); +int mmi_pmic_vote_force_active_set(struct votable *votable, u64 val); + +#endif /* __MMI_PMIC_VOTER_H */