Skip to content

Commit 99f75ce

Browse files
Martin Fuzzeybroonie
authored andcommitted
regulator: da9063: fix suspend
The .set_suspend_enable() and .set_suspend_disable() methods are not supposed to immediately change the regulator state but just indicated if the regulator should be enabled or disabled when standby mode is entered (by a hardware signal). However currently they set control the SEL bits in the DVC registers, which causes the voltage to change to immediately between the "A" (normal) and "B" (standby) values as programmed and does nothing for the enable state... This means that "regulator-on-in-suspend" does not work (the regulator is switched off when the PMIC enters standby mode on the hardware signal) and, potentially, depending on the A and B voltage configurations the voltage could be incorrectly changed *before* actually entering suspend. The right bit to use for the functionality is the "CONF" bit in the "CONT" register. The detailed register description says "Sequencer target state" for this bit which is not very clear but the functional description is clearer. >From 5.1.5 System Enable: De-asserting SYS_EN (changing from active to passive state) clears control SYSTEM_EN which triggers a power down sequence into hibernate/standby mode ... With the exception of supplies that have the xxxx_CONF control bit asserted, all regulators in power domains POWER1, POWER, and SYSTEM are sequentially disabled in reverse order. Regulators with the <x>_CONF bit set remain on but change the active voltage controlregisters from V<x>_A to V<x>_B (if V<x>_B is notalready selected). Signed-off-by: Martin Fuzzey <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 02fbabd commit 99f75ce

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

drivers/regulator/da9063-regulator.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ struct da9063_regulator_info {
100100
.desc.vsel_mask = DA9063_V##regl_name##_MASK, \
101101
.desc.linear_min_sel = DA9063_V##regl_name##_BIAS, \
102102
.sleep = BFIELD(DA9063_REG_V##regl_name##_A, DA9063_LDO_SL), \
103+
.suspend = BFIELD(DA9063_REG_##regl_name##_CONT, DA9063_LDO_CONF), \
103104
.suspend_sleep = BFIELD(DA9063_REG_V##regl_name##_B, DA9063_LDO_SL), \
104105
.suspend_vsel_reg = DA9063_REG_V##regl_name##_B
105106

@@ -124,6 +125,7 @@ struct da9063_regulator_info {
124125
.desc.vsel_mask = DA9063_VBUCK_MASK, \
125126
.desc.linear_min_sel = DA9063_VBUCK_BIAS, \
126127
.sleep = BFIELD(DA9063_REG_V##regl_name##_A, DA9063_BUCK_SL), \
128+
.suspend = BFIELD(DA9063_REG_##regl_name##_CONT, DA9063_BUCK_CONF), \
127129
.suspend_sleep = BFIELD(DA9063_REG_V##regl_name##_B, DA9063_BUCK_SL), \
128130
.suspend_vsel_reg = DA9063_REG_V##regl_name##_B, \
129131
.mode = BFIELD(DA9063_REG_##regl_name##_CFG, DA9063_BUCK_MODE_MASK)
@@ -465,72 +467,61 @@ static const struct da9063_regulator_info da9063_regulator_info[] = {
465467
da9063_buck_a_limits,
466468
DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK),
467469
DA9063_BUCK_COMMON_FIELDS(BCORE1),
468-
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE1_SEL),
469470
},
470471
{
471472
DA9063_BUCK(DA9063, BCORE2, 300, 10, 1570,
472473
da9063_buck_a_limits,
473474
DA9063_REG_BUCK_ILIM_C, DA9063_BCORE2_ILIM_MASK),
474475
DA9063_BUCK_COMMON_FIELDS(BCORE2),
475-
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE2_SEL),
476476
},
477477
{
478478
DA9063_BUCK(DA9063, BPRO, 530, 10, 1800,
479479
da9063_buck_a_limits,
480480
DA9063_REG_BUCK_ILIM_B, DA9063_BPRO_ILIM_MASK),
481481
DA9063_BUCK_COMMON_FIELDS(BPRO),
482-
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBPRO_SEL),
483482
},
484483
{
485484
DA9063_BUCK(DA9063, BMEM, 800, 20, 3340,
486485
da9063_buck_b_limits,
487486
DA9063_REG_BUCK_ILIM_A, DA9063_BMEM_ILIM_MASK),
488487
DA9063_BUCK_COMMON_FIELDS(BMEM),
489-
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBMEM_SEL),
490488
},
491489
{
492490
DA9063_BUCK(DA9063, BIO, 800, 20, 3340,
493491
da9063_buck_b_limits,
494492
DA9063_REG_BUCK_ILIM_A, DA9063_BIO_ILIM_MASK),
495493
DA9063_BUCK_COMMON_FIELDS(BIO),
496-
.suspend = BFIELD(DA9063_REG_DVC_2, DA9063_VBIO_SEL),
497494
},
498495
{
499496
DA9063_BUCK(DA9063, BPERI, 800, 20, 3340,
500497
da9063_buck_b_limits,
501498
DA9063_REG_BUCK_ILIM_B, DA9063_BPERI_ILIM_MASK),
502499
DA9063_BUCK_COMMON_FIELDS(BPERI),
503-
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBPERI_SEL),
504500
},
505501
{
506502
DA9063_BUCK(DA9063, BCORES_MERGED, 300, 10, 1570,
507503
da9063_bcores_merged_limits,
508504
DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK),
509505
/* BCORES_MERGED uses the same register fields as BCORE1 */
510506
DA9063_BUCK_COMMON_FIELDS(BCORE1),
511-
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE1_SEL),
512507
},
513508
{
514509
DA9063_BUCK(DA9063, BMEM_BIO_MERGED, 800, 20, 3340,
515510
da9063_bmem_bio_merged_limits,
516511
DA9063_REG_BUCK_ILIM_A, DA9063_BMEM_ILIM_MASK),
517512
/* BMEM_BIO_MERGED uses the same register fields as BMEM */
518513
DA9063_BUCK_COMMON_FIELDS(BMEM),
519-
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBMEM_SEL),
520514
},
521515
{
522516
DA9063_LDO(DA9063, LDO3, 900, 20, 3440),
523-
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VLDO3_SEL),
524517
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO3_LIM),
525518
},
526519
{
527520
DA9063_LDO(DA9063, LDO7, 900, 50, 3600),
528-
.suspend = BFIELD(DA9063_REG_LDO7_CONT, DA9063_VLDO7_SEL),
529521
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO7_LIM),
530522
},
531523
{
532524
DA9063_LDO(DA9063, LDO8, 900, 50, 3600),
533-
.suspend = BFIELD(DA9063_REG_LDO8_CONT, DA9063_VLDO8_SEL),
534525
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO8_LIM),
535526
},
536527
{
@@ -539,36 +530,29 @@ static const struct da9063_regulator_info da9063_regulator_info[] = {
539530
},
540531
{
541532
DA9063_LDO(DA9063, LDO11, 900, 50, 3600),
542-
.suspend = BFIELD(DA9063_REG_LDO11_CONT, DA9063_VLDO11_SEL),
543533
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO11_LIM),
544534
},
545535

546536
/* The following LDOs are present only on DA9063, not on DA9063L */
547537
{
548538
DA9063_LDO(DA9063, LDO1, 600, 20, 1860),
549-
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VLDO1_SEL),
550539
},
551540
{
552541
DA9063_LDO(DA9063, LDO2, 600, 20, 1860),
553-
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VLDO2_SEL),
554542
},
555543
{
556544
DA9063_LDO(DA9063, LDO4, 900, 20, 3440),
557-
.suspend = BFIELD(DA9063_REG_DVC_2, DA9063_VLDO4_SEL),
558545
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO4_LIM),
559546
},
560547
{
561548
DA9063_LDO(DA9063, LDO5, 900, 50, 3600),
562-
.suspend = BFIELD(DA9063_REG_LDO5_CONT, DA9063_VLDO5_SEL),
563549
},
564550
{
565551
DA9063_LDO(DA9063, LDO6, 900, 50, 3600),
566-
.suspend = BFIELD(DA9063_REG_LDO6_CONT, DA9063_VLDO6_SEL),
567552
},
568553

569554
{
570555
DA9063_LDO(DA9063, LDO10, 900, 50, 3600),
571-
.suspend = BFIELD(DA9063_REG_LDO10_CONT, DA9063_VLDO10_SEL),
572556
},
573557
};
574558

0 commit comments

Comments
 (0)