Skip to content

Commit e9ab2b8

Browse files
Xu YangUlf Hansson
authored andcommitted
pmdomain: imx8mp-blk-ctrl: Keep gpc power domain on for system wakeup
Current design will power off all dependent GPC power domains in imx8mp_blk_ctrl_suspend(), even though the user device has enabled wakeup capability. The result is that wakeup function never works for such device. An example will be USB wakeup on i.MX8MP. PHY device '382f0040.usb-phy' is attached to power domain 'hsioblk-usb-phy2' which is spawned by hsio block control. A virtual power domain device 'genpd:3:32f10000.blk-ctrl' is created to build connection with 'hsioblk-usb-phy2' and it depends on GPC power domain 'usb-otg2'. If device '382f0040.usb-phy' enable wakeup, only power domain 'hsioblk-usb-phy2' keeps on during system suspend, power domain 'usb-otg2' is off all the time. So the wakeup event can't happen. In order to further establish a connection between the power domains related to GPC and block control during system suspend, register a genpd power on/off notifier for the power_dev. This allows us to prevent the GPC power domain from being powered off, in case the block control power domain is kept on to serve system wakeup. Suggested-by: Ulf Hansson <[email protected]> Fixes: 556f5cf ("soc: imx: add i.MX8MP HSIO blk-ctrl") Cc: [email protected] Signed-off-by: Xu Yang <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent 6bd8b4a commit e9ab2b8

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

drivers/pmdomain/imx/imx8mp-blk-ctrl.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct imx8mp_blk_ctrl_domain {
6565
struct icc_bulk_data paths[DOMAIN_MAX_PATHS];
6666
struct device *power_dev;
6767
struct imx8mp_blk_ctrl *bc;
68+
struct notifier_block power_nb;
6869
int num_paths;
6970
int id;
7071
};
@@ -594,6 +595,20 @@ static int imx8mp_blk_ctrl_power_off(struct generic_pm_domain *genpd)
594595
return 0;
595596
}
596597

598+
static int imx8mp_blk_ctrl_gpc_notifier(struct notifier_block *nb,
599+
unsigned long action, void *data)
600+
{
601+
struct imx8mp_blk_ctrl_domain *domain =
602+
container_of(nb, struct imx8mp_blk_ctrl_domain, power_nb);
603+
604+
if (action == GENPD_NOTIFY_PRE_OFF) {
605+
if (domain->genpd.status == GENPD_STATE_ON)
606+
return NOTIFY_BAD;
607+
}
608+
609+
return NOTIFY_OK;
610+
}
611+
597612
static struct lock_class_key blk_ctrl_genpd_lock_class;
598613

599614
static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)
@@ -698,6 +713,14 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)
698713
goto cleanup_pds;
699714
}
700715

716+
domain->power_nb.notifier_call = imx8mp_blk_ctrl_gpc_notifier;
717+
ret = dev_pm_genpd_add_notifier(domain->power_dev, &domain->power_nb);
718+
if (ret) {
719+
dev_err_probe(dev, ret, "failed to add power notifier\n");
720+
dev_pm_domain_detach(domain->power_dev, true);
721+
goto cleanup_pds;
722+
}
723+
701724
domain->genpd.name = data->name;
702725
domain->genpd.power_on = imx8mp_blk_ctrl_power_on;
703726
domain->genpd.power_off = imx8mp_blk_ctrl_power_off;
@@ -707,6 +730,7 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)
707730
ret = pm_genpd_init(&domain->genpd, NULL, true);
708731
if (ret) {
709732
dev_err_probe(dev, ret, "failed to init power domain\n");
733+
dev_pm_genpd_remove_notifier(domain->power_dev);
710734
dev_pm_domain_detach(domain->power_dev, true);
711735
goto cleanup_pds;
712736
}
@@ -755,6 +779,7 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)
755779
cleanup_pds:
756780
for (i--; i >= 0; i--) {
757781
pm_genpd_remove(&bc->domains[i].genpd);
782+
dev_pm_genpd_remove_notifier(bc->domains[i].power_dev);
758783
dev_pm_domain_detach(bc->domains[i].power_dev, true);
759784
}
760785

@@ -774,6 +799,7 @@ static void imx8mp_blk_ctrl_remove(struct platform_device *pdev)
774799
struct imx8mp_blk_ctrl_domain *domain = &bc->domains[i];
775800

776801
pm_genpd_remove(&domain->genpd);
802+
dev_pm_genpd_remove_notifier(domain->power_dev);
777803
dev_pm_domain_detach(domain->power_dev, true);
778804
}
779805

0 commit comments

Comments
 (0)