Skip to content

Commit ef8d1d5

Browse files
committed
lk2nd: hw: regulator: gpl: Add PM8937 support and improve error logging
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`.
1 parent 2d4c54b commit ef8d1d5

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed

lk2nd/fastboot/debug/regulator.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,16 @@ static void cmd_oem_debug_spmi_regulators(const char *arg, void *data, unsigned
5151

5252
snprintf(response, sizeof(response), "Detected PMIC %#x", target);
5353
fastboot_info(response);
54-
dump_regulators(spmi_regulator_probe(target));
54+
55+
struct regulator_dev *rdev = spmi_regulator_probe(target);
56+
if (!rdev) {
57+
snprintf(response, sizeof(response), "No regulators found");
58+
fastboot_info(response);
59+
} else {
60+
snprintf(response, sizeof(response), "Regulator list:");
61+
fastboot_info(response);
62+
dump_regulators(rdev);
63+
}
5564
}
5665
fastboot_okay("");
5766
}

lk2nd/hw/regulator/gpl/qcom-spmi-pmic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#define PM8998_SUBTYPE 0x14
3232
#define PMI8998_SUBTYPE 0x15
3333
#define PM8005_SUBTYPE 0x18
34+
#define PM8937_SUBTYPE 0x19
3435
#define PM660L_SUBTYPE 0x1a
3536
#define PM660_SUBTYPE 0x1b
3637
#define PM8150_SUBTYPE 0x1e

lk2nd/hw/regulator/gpl/qcom_spmi-regulator.c

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,6 +2269,39 @@ static const struct spmi_regulator_data pm8916_regulators[] = {
22692269
{ }
22702270
};
22712271

2272+
static const struct spmi_regulator_data pm8937_regulators[] = {
2273+
{ "s1", 0x1400, "vdd_s1", },
2274+
{ "s2", 0x1700, "vdd_s2", },
2275+
{ "s3", 0x1a00, "vdd_s3", },
2276+
{ "s4", 0x1d00, "vdd_s4", },
2277+
{ "s5", 0x2000, "vdd_s5", },
2278+
{ "s6", 0x2300, "vdd_s6", },
2279+
{ "l1", 0x4000, "vdd_l1_l19", },
2280+
{ "l2", 0x4100, "vdd_l2_l23", },
2281+
{ "l3", 0x4200, "vdd_l3", },
2282+
{ "l4", 0x4300, "vdd_l4_l5_l6_l7_l16", },
2283+
{ "l5", 0x4400, "vdd_l4_l5_l6_l7_l16", },
2284+
{ "l6", 0x4500, "vdd_l4_l5_l6_l7_l16", },
2285+
{ "l7", 0x4600, "vdd_l4_l5_l6_l7_l16", },
2286+
{ "l8", 0x4700, "vdd_l8_l11_l12_l17_l22", },
2287+
{ "l9", 0x4800, "vdd_l9_l10_l13_l14_l15_l18", },
2288+
{ "l10", 0x4900, "vdd_l9_l10_l13_l14_l15_l18", },
2289+
{ "l11", 0x4a00, "vdd_l8_l11_l12_l17_l22", },
2290+
{ "l12", 0x4b00, "vdd_l8_l11_l12_l17_l22", },
2291+
{ "l13", 0x4c00, "vdd_l9_l10_l13_l14_l15_l18", },
2292+
{ "l14", 0x4d00, "vdd_l9_l10_l13_l14_l15_l18", },
2293+
{ "l15", 0x4e00, "vdd_l9_l10_l13_l14_l15_l18", },
2294+
{ "l16", 0x4f00, "vdd_l4_l5_l6_l7_l16", },
2295+
{ "l17", 0x5000, "vdd_l8_l11_l12_l17_l22", },
2296+
{ "l18", 0x5100, "vdd_l9_l10_l13_l14_l15_l18", },
2297+
{ "l19", 0x5200, "vdd_l1_l19", },
2298+
{ "l20", 0x5300, "vdd_l20_l21", },
2299+
{ "l21", 0x5400, "vdd_l21_l21", },
2300+
{ "l22", 0x5500, "vdd_l8_l11_l12_l17_l22", },
2301+
{ "l23", 0x5600, "vdd_l2_l23", },
2302+
{ }
2303+
};
2304+
22722305
static const struct spmi_regulator_data pm8941_regulators[] = {
22732306
{ "s1", 0x1400, "vdd_s1", },
22742307
{ "s2", 0x1700, "vdd_s2", },
@@ -2586,6 +2619,7 @@ static const struct spmi_regulator_match qcom_spmi_regulator_match[] = {
25862619
{ .subtype = PM8226_SUBTYPE, .sid = 1, .data = pm8226_regulators },
25872620
{ .subtype = PM8841_SUBTYPE, .sid = 5, .data = pm8841_regulators },
25882621
{ .subtype = PM8916_SUBTYPE, .sid = 1, .data = pm8916_regulators },
2622+
{ .subtype = PM8937_SUBTYPE, .sid = 1, .data = pm8937_regulators },
25892623
{ .subtype = PM8941_SUBTYPE, .sid = 1, .data = pm8941_regulators },
25902624
{ .subtype = PM8950_SUBTYPE, .sid = 1, .data = pm8950_regulators },
25912625
{ .subtype = PM8994_SUBTYPE, .sid = 1, .data = pm8994_regulators },
@@ -2619,15 +2653,19 @@ struct regulator_dev *spmi_regulator_probe(uint8_t subtype)
26192653
unsigned int i;
26202654
int ret;
26212655

2622-
if (!match)
2656+
if (!match) {
2657+
dprintf(CRITICAL, "Failed to find SPMI regulator match for subtype 0x%02X\n", subtype);
26232658
return NULL;
2659+
}
26242660

26252661
for (data = match->data; data->name; ++data)
26262662
++num;
26272663

26282664
vreg = calloc(num, sizeof(*vreg));
2629-
if (!vreg)
2665+
if (!vreg) {
2666+
dprintf(CRITICAL, "Failed to allocate memory for SPMI regulator\n");
26302667
return NULL;
2668+
}
26312669

26322670
for (i = 0; i < num; ++i) {
26332671
const struct spmi_regulator_data *reg = &match->data[i];
@@ -2637,9 +2675,11 @@ struct regulator_dev *spmi_regulator_probe(uint8_t subtype)
26372675
vreg[i].base = (match->sid << 16) | reg->base;
26382676

26392677
ret = spmi_regulator_match(&vreg[i], reg->force_type);
2640-
if (ret)
2641-
dprintf(CRITICAL, "Failed to match SPMI regulator %s\n",
2642-
reg->name);
2678+
if (ret) {
2679+
dprintf(CRITICAL, "Failed to match SPMI regulator %s\n", reg->name);
2680+
dprintf(CRITICAL, "subtype=%u, force_type=0x%02X, logical_type=%u\n",
2681+
subtype, reg->force_type, vreg[i].logical_type);
2682+
}
26432683

26442684
if (vreg[i].set_points)
26452685
vreg[i].desc.driver_type = vreg[i].set_points->type;

0 commit comments

Comments
 (0)