From 6ab7b0828a7e5339e17f16aca28812983421e3bc Mon Sep 17 00:00:00 2001 From: David Collins Date: Fri, 11 May 2018 20:01:34 -0700 Subject: [PATCH 1/2] mfd: qcom-spmi-pmic: add support for slow SPMI busses Add device tree support for configuring if mutexes or spinlocks should be used in the regmap configuration (i.e. the fast_io element value). This ensures that qcom-spmi-pmic slave devices can be used with SPMI busses that must operate in process context. Change-Id: I3abdee36935457db497ce6ff2a242755fc3aff90 Signed-off-by: David Collins Signed-off-by: Subbaraman Narayanamurthy --- drivers/mfd/qcom-spmi-pmic.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/mfd/qcom-spmi-pmic.c b/drivers/mfd/qcom-spmi-pmic.c index 1cacc00aa6c9..c04d9892b8f9 100644 --- a/drivers/mfd/qcom-spmi-pmic.c +++ b/drivers/mfd/qcom-spmi-pmic.c @@ -1,7 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2014, The Linux Foundation. All rights reserved. - */ +/* Copyright (c) 2014, 2017-2018, The Linux Foundation. All rights reserved. */ #include #include @@ -141,11 +139,23 @@ static const struct regmap_config spmi_regmap_config = { .fast_io = true, }; +static const struct regmap_config spmi_regmap_can_sleep_config = { + .reg_bits = 16, + .val_bits = 8, + .max_register = 0xffff, + .fast_io = false, +}; + static int pmic_spmi_probe(struct spmi_device *sdev) { + struct device_node *root = sdev->dev.of_node; struct regmap *regmap; - regmap = devm_regmap_init_spmi_ext(sdev, &spmi_regmap_config); + if (of_property_read_bool(root, "qcom,can-sleep")) + regmap = devm_regmap_init_spmi_ext(sdev, + &spmi_regmap_can_sleep_config); + else + regmap = devm_regmap_init_spmi_ext(sdev, &spmi_regmap_config); if (IS_ERR(regmap)) return PTR_ERR(regmap); From 8b067b6672bcd27d53f019316909ac63302944d8 Mon Sep 17 00:00:00 2001 From: Abhijeet Dharmapurikar Date: Fri, 1 Nov 2019 14:32:49 -0700 Subject: [PATCH 2/2] mfd: qcom-spmi-pmic: instantiate pmic peripherals at arch_initcall The spmi_devices spawn platform devices for pmic peripherals. Some of these devices are required early on in the boot process. Initialize the driver at arch_initcall to avoid unnecessary probe deferrals. Change-Id: I38474bedcb284ed5a7df1ec8d26f680787f2c074 Signed-off-by: Abhijeet Dharmapurikar Signed-off-by: Subbaraman Narayanamurthy [collinsd@codeaurora.org: add module exit function] Signed-off-by: David Collins --- drivers/mfd/qcom-spmi-pmic.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/qcom-spmi-pmic.c b/drivers/mfd/qcom-spmi-pmic.c index c04d9892b8f9..f86d3514e08d 100644 --- a/drivers/mfd/qcom-spmi-pmic.c +++ b/drivers/mfd/qcom-spmi-pmic.c @@ -1,5 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2014, 2017-2018, The Linux Foundation. All rights reserved. */ +/* + * Copyright (c) 2014-2015, 2017-2019, The Linux Foundation. + * All rights reserved. + */ #include #include @@ -175,7 +178,18 @@ static struct spmi_driver pmic_spmi_driver = { .of_match_table = pmic_spmi_id_table, }, }; -module_spmi_driver(pmic_spmi_driver); + +static int __init pmic_spmi_init(void) +{ + return spmi_driver_register(&pmic_spmi_driver); +} +arch_initcall(pmic_spmi_init); + +static void __exit pmic_spmi_exit(void) +{ + spmi_driver_unregister(&pmic_spmi_driver); +} +module_exit(pmic_spmi_exit); MODULE_DESCRIPTION("Qualcomm SPMI PMIC driver"); MODULE_ALIAS("spmi:spmi-pmic");