greybus: arche-platform: Export gpio (reset & sys_boot) to user
authorVaibhav Hiremath <vaibhav.hiremath@linaro.org>
Wed, 6 Jan 2016 06:01:20 +0000 (11:31 +0530)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 7 Jan 2016 04:00:35 +0000 (20:00 -0800)
In order to allow user to flash the firmware to,

SVC:
user need to assert the reset first, set sysboot pin and
deassert reset. And then issue a flashing command.

And APB:
User need to assert the reset first, and then issue flashing
command.

So this patch exports the gpio's to user.

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

index f02b8add6ebc4857c9d73934216301a9a3ab8aa2..8046e1eced83e4f71db6ad9399c13d6a9cc55e78 100644 (file)
@@ -71,6 +71,17 @@ static inline void deassert_gpio(unsigned int gpio)
        gpio_set_value(gpio, 0);
 }
 
+/* Export gpio's to user space */
+static void export_gpios(struct arche_apb_ctrl_drvdata *apb)
+{
+       gpio_export(apb->resetn_gpio, false);
+}
+
+static void unexport_gpios(struct arche_apb_ctrl_drvdata *apb)
+{
+       gpio_unexport(apb->resetn_gpio);
+}
+
 static irqreturn_t apb_ctrl_wake_detect_irq(int irq, void *devid)
 {
        struct arche_apb_ctrl_drvdata *apb = devid;
@@ -328,6 +339,8 @@ int arche_apb_ctrl_probe(struct platform_device *pdev)
 
        assert_gpio(apb->resetn_gpio);
 
+       export_gpios(apb);
+
        dev_info(&pdev->dev, "Device registered successfully\n");
        return 0;
 
@@ -344,6 +357,7 @@ int arche_apb_ctrl_remove(struct platform_device *pdev)
                apb_ctrl_cleanup(apb);
 
        platform_set_drvdata(pdev, NULL);
+       unexport_gpios(apb);
 
        return 0;
 }
index 50699520834fb17c9885a696b2af790c729eb973..e6fe0156e1284fa77cda920a3a4e311b09ff5233 100644 (file)
@@ -45,6 +45,19 @@ static inline void svc_reset_onoff(unsigned int gpio, bool onoff)
        gpio_set_value(gpio, onoff);
 }
 
+/* Export gpio's to user space */
+static void export_gpios(struct arche_platform_drvdata *arche_pdata)
+{
+       gpio_export(arche_pdata->svc_reset_gpio, false);
+       gpio_export(arche_pdata->svc_sysboot_gpio, false);
+}
+
+static void unexport_gpios(struct arche_platform_drvdata *arche_pdata)
+{
+       gpio_unexport(arche_pdata->svc_reset_gpio);
+       gpio_unexport(arche_pdata->svc_sysboot_gpio);
+}
+
 static void arche_platform_cleanup(struct arche_platform_drvdata *arche_pdata)
 {
        /* As part of exit, put APB back in reset state */
@@ -141,6 +154,8 @@ static int arche_platform_probe(struct platform_device *pdev)
        arche_pdata->num_apbs = of_get_child_count(np);
        dev_dbg(dev, "Number of APB's available - %d\n", arche_pdata->num_apbs);
 
+       export_gpios(arche_pdata);
+
        /* probe all childs here */
        ret = of_platform_populate(np, NULL, NULL, dev);
        if (ret)
@@ -169,6 +184,7 @@ static int arche_platform_remove(struct platform_device *pdev)
                arche_platform_cleanup(arche_pdata);
 
        platform_set_drvdata(pdev, NULL);
+       unexport_gpios(arche_pdata);
 
        return 0;
 }