MLK-11395-4 ARM: imx: add mipi phy regulator handling to gpcv2
authorSigned-off-by: Fancy Fang <chen.fang@freescale.com>
Tue, 1 Nov 2016 14:33:19 +0000 (16:33 +0200)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:48:05 +0000 (14:48 -0500)
Add mipi phy regulator notify callback to power on or power off this
phy along with the regulator enable/disable called. This will be used
by mipi dsi/csi later.

Signed-off-by: Fancy Fang <chen.fang@freescale.com>
arch/arm/boot/dts/imx7d.dtsi
arch/arm/mach-imx/gpcv2.c

index cc34894..fa32d93 100644 (file)
                #interrupt-cells = <3>;
                interrupt-parent = <&intc>;
                fsl,mf-mix-wakeup-irq = <0x54010000 0xc00 0x0 0x1040640>;
+               mipi-phy-supply = <&reg_1p0d>;
        };
 };
 
index e9e1a51..1d91852 100644 (file)
@@ -108,6 +108,7 @@ static u32 gpcv2_saved_imrs[IMR_NUM];
 static u32 gpcv2_mf_irqs[IMR_NUM];
 static u32 gpcv2_mf_request_on[IMR_NUM];
 static DEFINE_SPINLOCK(gpcv2_lock);
+static struct notifier_block nb_mipi;
 
 static int imx_gpcv2_irq_set_wake(struct irq_data *d, unsigned int on)
 {
@@ -577,6 +578,37 @@ static struct irq_domain_ops imx_gpcv2_domain_ops = {
        .free   = irq_domain_free_irqs_common,
 };
 
+static int imx_mipi_regulator_notify(struct notifier_block *nb,
+                                       unsigned long event,
+                                       void *ignored)
+{
+       u32 val = 0;
+
+       switch (event) {
+       case REGULATOR_EVENT_PRE_DO_ENABLE:
+               val = readl_relaxed(gpc_base + GPC_PGC_CPU_MAPPING);
+               writel_relaxed(val | BIT(2), gpc_base + GPC_PGC_CPU_MAPPING);
+
+               val = readl_relaxed(gpc_base + GPC_PU_PGC_SW_PUP_REQ);
+               writel_relaxed(val | BIT(0), gpc_base + GPC_PU_PGC_SW_PUP_REQ);
+               break;
+       case REGULATOR_EVENT_PRE_DO_DISABLE:
+               val = readl_relaxed(gpc_base + GPC_PU_PGC_SW_PDN_REQ);
+               writel_relaxed(val | BIT(0), gpc_base + GPC_PU_PGC_SW_PDN_REQ);
+
+               val = readl_relaxed(gpc_base + GPC_PGC_MIPI_PHY);
+               writel_relaxed(val | BIT(0), gpc_base + GPC_PGC_MIPI_PHY);
+
+               val = readl_relaxed(gpc_base + GPC_PGC_CPU_MAPPING);
+               writel_relaxed(val & ~BIT(2), gpc_base + GPC_PGC_CPU_MAPPING);
+               break;
+       default:
+               break;
+       }
+
+       return NOTIFY_OK;
+}
+
 static int __init imx_gpcv2_init(struct device_node *node,
                               struct device_node *parent)
 {
@@ -687,6 +719,26 @@ void __init imx_gpcv2_check_dt(void)
 
 static int imx_gpcv2_probe(struct platform_device *pdev)
 {
+       int ret;
+       struct regulator *mipi_reg;
+
+       if (cpu_is_imx7d()) {
+               mipi_reg = devm_regulator_get(&pdev->dev, "mipi-phy");
+               if (IS_ERR(mipi_reg)) {
+                       ret = PTR_ERR(mipi_reg);
+                       dev_info(&pdev->dev, "mipi regulator not ready.\n");
+                       return ret;
+               }
+               nb_mipi.notifier_call = &imx_mipi_regulator_notify;
+
+               ret = regulator_register_notifier(mipi_reg, &nb_mipi);
+               if (ret) {
+                       dev_err(&pdev->dev,
+                               "mipi regulator notifier request failed.\n");
+                       return ret;
+               }
+       }
+
        return 0;
 }