Lines Matching +full:spmi +full:- +full:pmic
1 // SPDX-License-Identifier: GPL-2.0-only
11 #include <linux/spmi.h>
15 #include <soc/qcom/qcom-spmi-pmic.h>
30 struct qcom_spmi_pmic pmic; member
65 { .compatible = "qcom,spmi-pmic", .data = N_USIDS(1) },
70 * A PMIC can be represented by multiple SPMI devices, but
71 * only the base PMIC device will contain a reference to
74 * This function takes a pointer to a pmic device and
75 * returns a pointer to the base PMIC device.
89 ctx = dev_get_drvdata(&sdev->dev); in qcom_pmic_get_base_usid()
95 if (sdev->usid % ctx->num_usids == 0) in qcom_pmic_get_base_usid()
98 function_parent_usid = sdev->usid; in qcom_pmic_get_base_usid()
103 * number of USIDs in the PMIC array, e.g. for a PMIC with 2 USIDs in qcom_pmic_get_base_usid()
107 spmi_bus = of_get_parent(sdev->dev.of_node); in qcom_pmic_get_base_usid()
116 if (pmic_addr == function_parent_usid - (ctx->num_usids - 1)) { in qcom_pmic_get_base_usid()
119 * If the base USID for this PMIC hasn't probed yet in qcom_pmic_get_base_usid()
124 return ERR_PTR(-EPROBE_DEFER); in qcom_pmic_get_base_usid()
127 } while (other_usid->sibling); in qcom_pmic_get_base_usid()
129 return ERR_PTR(-ENODATA); in qcom_pmic_get_base_usid()
133 struct qcom_spmi_pmic *pmic) in pmic_spmi_load_revid() argument
137 ret = regmap_read(map, PMIC_TYPE, &pmic->type); in pmic_spmi_load_revid()
141 if (pmic->type != PMIC_TYPE_VALUE) in pmic_spmi_load_revid()
144 ret = regmap_read(map, PMIC_SUBTYPE, &pmic->subtype); in pmic_spmi_load_revid()
148 pmic->name = of_match_device(pmic_spmi_id_table, dev)->compatible; in pmic_spmi_load_revid()
150 ret = regmap_read(map, PMIC_REV2, &pmic->rev2); in pmic_spmi_load_revid()
154 ret = regmap_read(map, PMIC_REV3, &pmic->minor); in pmic_spmi_load_revid()
158 ret = regmap_read(map, PMIC_REV4, &pmic->major); in pmic_spmi_load_revid()
162 if (pmic->subtype == PMI8998_SUBTYPE || pmic->subtype == PM660_SUBTYPE) { in pmic_spmi_load_revid()
163 ret = regmap_read(map, PMIC_FAB_ID, &pmic->fab_id); in pmic_spmi_load_revid()
174 if ((pmic->subtype == PM8941_SUBTYPE || pmic->subtype == PM8226_SUBTYPE) && in pmic_spmi_load_revid()
175 pmic->major < PMIC_REV4_V2) in pmic_spmi_load_revid()
176 pmic->major++; in pmic_spmi_load_revid()
178 if (pmic->subtype == PM8110_SUBTYPE) in pmic_spmi_load_revid()
179 pmic->minor = pmic->rev2; in pmic_spmi_load_revid()
182 pmic->subtype, pmic->name, pmic->major, pmic->minor); in pmic_spmi_load_revid()
188 * qcom_pmic_get() - Get a pointer to the base PMIC device
190 * This function takes a struct device for a driver which is a child of a PMIC.
191 * And locates the PMIC revision information for it.
193 * @dev: the pmic function device
199 struct qcom_spmi_dev *spmi; in qcom_pmic_get() local
202 * Make sure the device is actually a child of a PMIC in qcom_pmic_get()
204 if (!of_match_device(pmic_spmi_id_table, dev->parent)) in qcom_pmic_get()
205 return ERR_PTR(-EINVAL); in qcom_pmic_get()
207 sdev = qcom_pmic_get_base_usid(dev->parent); in qcom_pmic_get()
212 spmi = dev_get_drvdata(&sdev->dev); in qcom_pmic_get()
214 return &spmi->pmic; in qcom_pmic_get()
235 ctx = devm_kzalloc(&sdev->dev, sizeof(*ctx), GFP_KERNEL); in pmic_spmi_probe()
237 return -ENOMEM; in pmic_spmi_probe()
239 ctx->num_usids = (uintptr_t)of_device_get_match_data(&sdev->dev); in pmic_spmi_probe()
241 /* Only the first slave id for a PMIC contains this information */ in pmic_spmi_probe()
242 if (sdev->usid % ctx->num_usids == 0) { in pmic_spmi_probe()
243 ret = pmic_spmi_load_revid(regmap, &sdev->dev, &ctx->pmic); in pmic_spmi_probe()
249 return devm_of_platform_populate(&sdev->dev); in pmic_spmi_probe()
257 .name = "pmic-spmi",
263 MODULE_DESCRIPTION("Qualcomm SPMI PMIC driver");
264 MODULE_ALIAS("spmi:spmi-pmic");
267 MODULE_AUTHOR("Stanimir Varbanov <svarbanov@mm-sol.com>");