greybus: arche-platform: Add support for init-off feature
authorVaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tue, 19 Jul 2016 08:01:46 +0000 (13:31 +0530)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 20 Jul 2016 01:31:00 +0000 (18:31 -0700)
Disable wake_detect interrupt after request

As part of SW-4344/SW-7061, now we are enabling FW flashing
to all builds. That means check for need of FW upgrade is
going to be present in all builds, and moving to FW_FlASHING
mode from active is heavy operation; so the idea here is
simplify this process and save the boot time due to switching
back-n-forth between ACTIVE<=>FW_FLASHING modes.

So we decided to put unipro into OFF state by default on boot,
which can be changed through DT property. If arche-platform
device node has "arche,init-off" property set, then unipro
will be in OFF state on boot. User can bring it back by

 # echo active > /sys/devices/arche_platform*/state

And to simply the exit code of probe() fn the
arche_platform_coldboot_seq() has been shifted to the
bottom of the _probe() fn.

Testing Done: Tested on EVT2 platform, with and without
"arche,init-off" property, multiple times.
Note: I am seeing SW-7128, which is not related to these changes.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/arche-platform.c

index af78420..cbe8bdc 100644 (file)
@@ -672,8 +672,7 @@ static int arche_platform_probe(struct platform_device *pdev)
                dev_err(dev, "failed to request wake detect IRQ %d\n", ret);
                return ret;
        }
-
-       gpio_direction_input(arche_pdata->wake_detect_gpio);
+       disable_irq(arche_pdata->wake_detect_irq);
 
        ret = device_create_file(dev, &dev_attr_state);
        if (ret) {
@@ -681,38 +680,41 @@ static int arche_platform_probe(struct platform_device *pdev)
                return ret;
        }
 
-       mutex_lock(&arche_pdata->platform_state_mutex);
-       ret = arche_platform_coldboot_seq(arche_pdata);
-       if (ret) {
-               dev_err(dev, "Failed to cold boot svc %d\n", ret);
-               goto err_coldboot;
-       }
-
        ret = of_platform_populate(np, NULL, NULL, dev);
        if (ret) {
                dev_err(dev, "failed to populate child nodes %d\n", ret);
-               goto err_populate;
+               goto err_device_remove;
        }
 
        arche_pdata->pm_notifier.notifier_call = arche_platform_pm_notifier;
        ret = register_pm_notifier(&arche_pdata->pm_notifier);
-       mutex_unlock(&arche_pdata->platform_state_mutex);
 
        if (ret) {
                dev_err(dev, "failed to register pm notifier %d\n", ret);
-               goto err_populate;
+               goto err_device_remove;
        }
 
        /* Register callback pointer */
        arche_platform_change_state_cb = arche_platform_change_state;
 
+       /* Explicitly power off if requested */
+       if (!of_property_read_bool(pdev->dev.of_node, "arche,init-off")) {
+               mutex_lock(&arche_pdata->platform_state_mutex);
+               ret = arche_platform_coldboot_seq(arche_pdata);
+               if (ret) {
+                       dev_err(dev, "Failed to cold boot svc %d\n", ret);
+                       goto err_coldboot;
+               }
+               arche_platform_wd_irq_en(arche_pdata);
+               mutex_unlock(&arche_pdata->platform_state_mutex);
+       }
+
        dev_info(dev, "Device registered successfully\n");
        return 0;
 
-err_populate:
-       arche_platform_poweroff_seq(arche_pdata);
 err_coldboot:
        mutex_unlock(&arche_pdata->platform_state_mutex);
+err_device_remove:
        device_remove_file(&pdev->dev, &dev_attr_state);
        return ret;
 }