]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
usb: chipidea: usbmisc: add power lost check for imx6sx
authorLi Jun <jun.li@nxp.com>
Thu, 13 Oct 2022 15:14:40 +0000 (23:14 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 23 Oct 2022 12:34:53 +0000 (14:34 +0200)
imx6sx mega off can shutdown domain power supply if none of peripheral
in this domain is registered as wakeup source, this patch add related
codes to check if power is lost.

Signed-off-by: Li Jun <jun.li@nxp.com>
Link: https://lore.kernel.org/r/20221013151442.3262951-7-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/chipidea/usbmisc_imx.c

index aa815f6d3fe9a916a93033b45571cd89db49e99d..7bfbfc83cfe3c038aa9f81df2e56a20b9bb0556f 100644 (file)
@@ -939,6 +939,25 @@ static int usbmisc_imx7ulp_init(struct imx_usbmisc_data *data)
        return 0;
 }
 
+static int usbmisc_imx6sx_power_lost_check(struct imx_usbmisc_data *data)
+{
+       struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
+       unsigned long flags;
+       u32 val;
+
+       spin_lock_irqsave(&usbmisc->lock, flags);
+       val = readl(usbmisc->base + data->index * 4);
+       spin_unlock_irqrestore(&usbmisc->lock, flags);
+       /*
+        * Here use a power on reset value to judge
+        * if the controller experienced a power lost
+        */
+       if (val == 0x30001000)
+               return 1;
+       else
+               return 0;
+}
+
 static const struct usbmisc_ops imx25_usbmisc_ops = {
        .init = usbmisc_imx25_init,
        .post = usbmisc_imx25_post,
@@ -972,6 +991,7 @@ static const struct usbmisc_ops imx6sx_usbmisc_ops = {
        .init = usbmisc_imx6sx_init,
        .hsic_set_connect = usbmisc_imx6_hsic_set_connect,
        .hsic_set_clk = usbmisc_imx6_hsic_set_clk,
+       .power_lost_check = usbmisc_imx6sx_power_lost_check,
 };
 
 static const struct usbmisc_ops imx7d_usbmisc_ops = {