-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lk2nd: hw: regulator: gpl: Add PM8937 support and improve error logging #463
base: main
Are you sure you want to change the base?
lk2nd: hw: regulator: gpl: Add PM8937 support and improve error logging #463
Conversation
Add support for the PM8937 SPMI regulator and enhance error logging in the `spmi_regulator_probe` function. Also, improve debugging output in `cmd_oem_debug_spmi_regulators`.
123faf8
to
ef8d1d5
Compare
struct regulator_dev *rdev = spmi_regulator_probe(target); | ||
if (!rdev) { | ||
snprintf(response, sizeof(response), "No regulators found"); | ||
fastboot_info(response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fastboot_info("No regulators found")
should work I think, same below
@@ -2586,6 +2619,7 @@ static const struct spmi_regulator_match qcom_spmi_regulator_match[] = { | |||
{ .subtype = PM8226_SUBTYPE, .sid = 1, .data = pm8226_regulators }, | |||
{ .subtype = PM8841_SUBTYPE, .sid = 5, .data = pm8841_regulators }, | |||
{ .subtype = PM8916_SUBTYPE, .sid = 1, .data = pm8916_regulators }, | |||
{ .subtype = PM8937_SUBTYPE, .sid = 1, .data = pm8937_regulators }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is meant to be synced completely with upstream to add all the new entries. I just did that and pushed to main
, can you rebase to drop these changes?
@stephan-gh Hi, I did the rebase locally, here you have the code with the changes after the rebase. Should we modify this PR to add only this logs? diff --git a/lk2nd/fastboot/debug/regulator.c b/lk2nd/fastboot/debug/regulator.c
index 5fe25e52..3e7b52c5 100644
--- a/lk2nd/fastboot/debug/regulator.c
+++ b/lk2nd/fastboot/debug/regulator.c
@@ -51,7 +51,16 @@ static void cmd_oem_debug_spmi_regulators(const char *arg, void *data, unsigned
snprintf(response, sizeof(response), "Detected PMIC %#x", target);
fastboot_info(response);
- dump_regulators(spmi_regulator_probe(target));
+
+ struct regulator_dev *rdev = spmi_regulator_probe(target);
+ if (!rdev) {
+ snprintf(response, sizeof(response), "No regulators found");
+ fastboot_info(response);
+ } else {
+ snprintf(response, sizeof(response), "Regulator list:");
+ fastboot_info(response);
+ dump_regulators(rdev);
+ }
}
fastboot_okay("");
}
diff --git a/lk2nd/hw/regulator/gpl/qcom_spmi-regulator.c b/lk2nd/hw/regulator/gpl/qcom_spmi-regulator.c
index c84e1220..aae17f23 100644
--- a/lk2nd/hw/regulator/gpl/qcom_spmi-regulator.c
+++ b/lk2nd/hw/regulator/gpl/qcom_spmi-regulator.c
@@ -2750,15 +2750,19 @@ struct regulator_dev *spmi_regulator_probe(uint8_t subtype)
unsigned int i;
int ret;
- if (!match)
+ if (!match) {
+ dprintf(CRITICAL, "Failed to find SPMI regulator match for subtype 0x%02X\n", subtype);
return NULL;
+ }
for (data = match->data; data->name; ++data)
++num;
vreg = calloc(num, sizeof(*vreg));
- if (!vreg)
+ if (!vreg) {
+ dprintf(CRITICAL, "Failed to allocate memory for SPMI regulator\n");
return NULL;
+ }
for (i = 0; i < num; ++i) {
const struct spmi_regulator_data *reg = &match->data[i];
@@ -2768,9 +2772,11 @@ struct regulator_dev *spmi_regulator_probe(uint8_t subtype)
vreg[i].base = (match->sid << 16) | reg->base;
ret = spmi_regulator_match(&vreg[i], reg->force_type);
- if (ret)
- dprintf(CRITICAL, "Failed to match SPMI regulator %s\n",
- reg->name);
+ if (ret) {
+ dprintf(CRITICAL, "Failed to match SPMI regulator %s\n", reg->name);
+ dprintf(CRITICAL, "subtype=%u, force_type=0x%02X, logical_type=%u\n",
+ subtype, reg->force_type, vreg[i].logical_type);
+ }
if (vreg[i].set_points)
vreg[i].desc.driver_type = vreg[i].set_points->type; |
This PR is part of my research to enable support for sdcard on Nokia 5. I added support for the PM8937 SPMI regulator and enhance error logging in the
spmi_regulator_probe
function. Also, improve debugging output incmd_oem_debug_spmi_regulators
. Code extracted from this patch by danct12Tested on Nokia 5 (nokia-nd1):
Tested on Xiaomi Redmi 4 (xiaomi-santoni):