summaryrefslogtreecommitdiff
path: root/drivers/mfd/qcom-spmi-pmic.c
AgeCommit message (Collapse)AuthorFilesLines
2023-12-07mfd: qcom-spmi-pmic: Add support for PM8937Dang Huynh1-0/+1
Add the subtype and compatible strings for PM8937. The PM8937 is found in various SoCs, including MSM8917, MSM8937, MSM8940 and APQ variants. Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org> Signed-off-by: Dang Huynh <danct12@riseup.net> Link: https://lore.kernel.org/r/20231121-pm8937-v2-1-b0171ab62075@riseup.net Signed-off-by: Lee Jones <lee@kernel.org>
2023-11-01spmi: rename spmi device lookup helperJohan Hovold1-1/+1
Rename the SPMI device helper which is used to lookup a device from its OF node as spmi_find_device_by_of_node() so that it reflects the implementation and matches how other helpers like this are named. This will specifically make it more clear that this is a lookup function which returns a reference counted structure. Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Acked-by: Stephen Boyd <sboyd@kernel.org> Link: https://lore.kernel.org/r/20231003152927.15000-6-johan+linaro@kernel.org Signed-off-by: Lee Jones <lee@kernel.org>
2023-11-01mfd: Use device_get_match_data() in a bunch of driversRob Herring1-2/+4
Use preferred device_get_match_data() instead of of_match_device() to get the driver match data. With this, adjust the includes to explicitly include the correct headers. Reviewed-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20231017203612.2701060-1-robh@kernel.org Signed-off-by: Lee Jones <lee@kernel.org>
2023-11-01mfd: qcom-spmi-pmic: Switch to EXPORT_SYMBOL_GPL()Johan Hovold1-1/+1
Switch to using EXPORT_SYMBOL_GPL() for the revid helper as there is no reason not to use it. Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Acked-by: Caleb Connolly <caleb.connolly@linaro.org> Link: https://lore.kernel.org/r/20231003152927.15000-4-johan+linaro@kernel.org Signed-off-by: Lee Jones <lee@kernel.org>
2023-11-01mfd: qcom-spmi-pmic: Fix revid implementationJohan Hovold1-16/+53
The Qualcomm SPMI PMIC revid implementation is broken in multiple ways. First, it assumes that just because the sibling base device has been registered that means that it is also bound to a driver, which may not be the case (e.g. due to probe deferral or asynchronous probe). This could trigger a NULL-pointer dereference when attempting to access the driver data of the unbound device. Second, it accesses driver data of a sibling device directly and without any locking, which means that the driver data may be freed while it is being accessed (e.g. on driver unbind). Third, it leaks a struct device reference to the sibling device which is looked up using the spmi_device_from_of() every time a function (child) device is calling the revid function (e.g. on probe). Fix this mess by reimplementing the revid lookup so that it is done only at probe of the PMIC device; the base device fetches the revid info from the hardware, while any secondary SPMI device fetches the information from the base device and caches it so that it can be accessed safely from its children. If the base device has not been probed yet then probe of a secondary device is deferred. Fixes: e9c11c6e3a0e ("mfd: qcom-spmi-pmic: expose the PMIC revid information to clients") Cc: stable@vger.kernel.org # 6.0 Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Acked-by: Caleb Connolly <caleb.connolly@linaro.org> Link: https://lore.kernel.org/r/20231003152927.15000-3-johan+linaro@kernel.org Signed-off-by: Lee Jones <lee@kernel.org>
2023-11-01mfd: qcom-spmi-pmic: Fix reference leaks in revid helperJohan Hovold1-13/+19
The Qualcomm SPMI PMIC revid implementation is broken in multiple ways. First, it totally ignores struct device_node reference counting and leaks references to the parent bus node as well as each child it iterates over using an open-coded for_each_child_of_node(). Second, it leaks references to each spmi device on the bus that it iterates over by failing to drop the reference taken by the spmi_device_from_of() helper. Fix the struct device_node leaks by reimplementing the lookup using for_each_child_of_node() and adding the missing reference count decrements. Fix the sibling struct device leaks by dropping the unnecessary lookups of devices with the wrong USID. Note that this still leaves one struct device reference leak in case a base device is found but it is not the parent of the device used for the lookup. This will be addressed in a follow-on patch. Fixes: e9c11c6e3a0e ("mfd: qcom-spmi-pmic: expose the PMIC revid information to clients") Cc: stable@vger.kernel.org # 6.0 Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Acked-by: Caleb Connolly <caleb.connolly@linaro.org> Link: https://lore.kernel.org/r/20231003152927.15000-2-johan+linaro@kernel.org Signed-off-by: Lee Jones <lee@kernel.org>
2022-09-28mfd: qcom-spmi-pmic: Add support for PMP8074Robert Marko1-0/+1
Add support for PMP8074 PMIC which is a companion PMIC for the Qualcomm IPQ8074 SoC-s. It shares the same subtype identifier as PM8901. Signed-off-by: Robert Marko <robimarko@gmail.com> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20220818221815.346233-2-robimarko@gmail.com
2022-06-18mfd: qcom-spmi-pmic: read fab id on supported PMICsCaleb Connolly1-0/+7
The PMI8998 and PM660 expose the fab_id, this is needed by drivers like the RRADC to calibrate ADC values. Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Tested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Acked-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20220429220904.137297-4-caleb.connolly@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-18mfd: qcom-spmi-pmic: expose the PMIC revid information to clientsCaleb Connolly1-90/+175
Some PMIC functions such as the RRADC need to be aware of the PMIC chip revision information to implement errata or otherwise adjust behaviour, export the PMIC information to enable this. This is specifically required to enable the RRADC to adjust coefficients based on which chip fab the PMIC was produced in, this can vary per unique device and therefore has to be read at runtime. Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Tested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Acked-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20220429220904.137297-3-caleb.connolly@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-11-05mfd: qcom-spmi-pmic: Add missing PMICs supported by socinfoBjorn Andersson1-0/+17
The Qualcomm socinfo driver has eight more PMICs described, add these to the SPMI PMIC driver as well. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211017161218.2378176-4-bjorn.andersson@linaro.org
2021-11-05mfd: qcom-spmi-pmic: Sort compatibles in the driverBjorn Andersson1-15/+15
Sort the compatibles in the driver, to make it easier to validate that the DT binding and driver are in sync. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211017161218.2378176-2-bjorn.andersson@linaro.org
2020-11-19mfd: qcom-spmi-pmic: Add support for PM660/PM660LAngeloGioacchino Del Regno1-0/+4
Add the subtype and compatible strings for PM660 and PM660L, found in various SoCs, including SDM630, SDM636, SDM660 and SDA variants. Signed-off-by: AngeloGioacchino Del Regno <kholk11@gmail.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2019-11-11mfd: qcom-spmi-pmic: Add support for PM/PMI8950Angelo G. Del Regno1-0/+4
Add the subtype and compatible strings for PM8950 and PMI8950, found in various SoCs, including MSM8953, MSM8956, MSM8976 and APQ variants. Signed-off-by: Angelo G. Del Regno <kholk11@gmail.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2019-06-05treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284Thomas Gleixner1-9/+1
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 and only version 2 as published by the free software foundation this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 294 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190529141900.825281744@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-04mfd: qcom-spmi-pmic: Add support for pm8005, pm8998 and pmi8998Stephen Boyd1-0/+6
Add the compatibles and PMIC ids for the pm8005, pm8998, and pmi8998 PMICS found on MSM8998 and SDM845 based platforms. Cc: <devicetree@vger.kernel.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Rob Herring <robh@kernel.org> Reviewed-by: Doug Anderson <dianders@chromium.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2017-07-06mfd: qcom-spmi-pmic: Use devm_of_platform_populate()Benjamin Gaignard1-8/+1
Usage of devm_of_platform_populate() simplify driver code by allowing to delete pmic_spmi_remove(). Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2016-01-11mfd: qcom-spmi-pmic: Don't access non-existing registersIvan T. Ivanov1-1/+3
Revision ID registers are available only on devices with Slave IDs that are even, so don't make access to unavailable registers. Signed-off-by: Ivan T. Ivanov <ivan.ivanov@linaro.org> [sboyd@codeaurora.org: Consider all slave ids that are even] Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2015-03-30mfd: qcom-spmi-pmic: Add specific compatible strings for Qualcomm's SPMI PMIC'sIvan T. Ivanov1-7/+96
Some of the PMIC's could have specific regmap configuration tables in future, so add specific compatible strings for known PMIC's. Also print runtime detected chip revision information. Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com> Acked-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-09-26mfd: Add support for Qualcomm SPMI PMICsJosh Cartwright1-0/+67
The Qualcomm SPMI PMIC chips are components used with the Snapdragon 800 series SoC family. This driver exists largely as a glue mfd component, it exists to be an owner of an SPMI regmap for children devices described in device tree. Signed-off-by: Josh Cartwright <joshc@codeaurora.org> Signed-off-by: Stanimir Varbanov <svarbanov@mm-sol.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>