misc: tegra-baseband: sysedp support
Neil Patel [Fri, 8 Nov 2013 16:23:46 +0000 (11:23 -0500)]
Support is added for sysedp which is an updated version of the edp
framework.

Bug 1379950

Change-Id: I9c28fe27fd0de14fec71edf77436fc732f439af0
Signed-off-by: Neil Patel <neilp@nvidia.com>
Reviewed-on: http://git-master/r/328364
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Steve Lin <stlin@nvidia.com>

drivers/misc/tegra-baseband/tegra_usb_modem_power.c
include/linux/platform_data/tegra_usb_modem_power.h

index 5709e0f..21e9820 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/pm_qos.h>
 #include <linux/regulator/consumer.h>
 #include <linux/edp.h>
+#include <linux/sysedp.h>
 #include <mach/gpio-tegra.h>
 #include <linux/platform_data/tegra_usb_modem_power.h>
 
@@ -87,6 +88,9 @@ struct tegra_usb_modem {
        unsigned int i_thresh_lte_adjperiod; /* lte i_thresh adj period */
        struct work_struct edp_work;
        struct mutex edp_lock;
+       struct sysedp_consumer *sysedpc;
+       unsigned int sysedpc_state_updated;
+       struct work_struct sysedp_work;
 };
 
 
@@ -186,6 +190,19 @@ done:
        mutex_unlock(&modem->edp_lock);
 }
 
+static void sysedp_work(struct work_struct *ws)
+{
+       struct tegra_usb_modem *modem = container_of(ws, struct tegra_usb_modem,
+                                                    sysedp_work);
+
+       mutex_lock(&modem->lock);
+
+       sysedp_set_state(modem->sysedpc, 1);
+       modem->sysedpc_state_updated = 1;
+
+       mutex_unlock(&modem->lock);
+}
+
 static irqreturn_t tegra_usb_modem_wake_thread(int irq, void *data)
 {
        struct tegra_usb_modem *modem = (struct tegra_usb_modem *)data;
@@ -240,6 +257,9 @@ static irqreturn_t tegra_usb_modem_boot_thread(int irq, void *data)
        if (modem->edp_initialized && !v)
                queue_work(modem->wq, &modem->edp_work);
 
+       if (modem->sysedpc && !modem->sysedpc_state_updated)
+               queue_work(modem->wq, &modem->sysedp_work);
+
        /* USB disconnect maybe on going... */
        mutex_lock(&modem->lock);
        if (modem->udev && modem->udev->state != USB_STATE_NOTATTACHED)
@@ -821,6 +841,11 @@ static int mdm_init(struct tegra_usb_modem *modem, struct platform_device *pdev)
                modem->edp_initialized = 1;
        }
 
+       modem->sysedpc = sysedp_create_consumer(modem->pdata->sysedpc_name,
+                                               modem->pdata->sysedpc_name);
+       if (modem->sysedpc)
+               INIT_WORK(&modem->sysedp_work, sysedp_work);
+
        /* get modem operations from platform data */
        modem->ops = (const struct tegra_modem_operations *)pdata->ops;
 
@@ -914,6 +939,11 @@ error:
        if (modem->boot_irq)
                free_irq(modem->boot_irq, modem);
 
+       if (modem->sysedpc) {
+               cancel_work_sync(&modem->sysedp_work);
+               sysedp_free_consumer(modem->sysedpc);
+       }
+
        if (modem->edp_initialized) {
                edp_attrs = edp_attributes;
                while ((attr = *edp_attrs++))
@@ -976,6 +1006,11 @@ static int __exit tegra_usb_modem_remove(struct platform_device *pdev)
        if (modem->sysfs_file_created)
                device_remove_file(&pdev->dev, &dev_attr_load_host);
 
+       if (modem->sysedpc) {
+               cancel_work_sync(&modem->sysedp_work);
+               sysedp_free_consumer(modem->sysedpc);
+       }
+
        if (modem->edp_initialized) {
                cancel_work_sync(&modem->edp_work);
 
index 3954f8b..0ecccbd 100644 (file)
@@ -56,6 +56,7 @@ struct tegra_usb_modem_power_platform_data {
        unsigned int i_breach_ppm;
        unsigned int i_thresh_3g_adjperiod;
        unsigned int i_thresh_lte_adjperiod;
+       char *sysedpc_name;             /* sysedp consumer name */
 };
 
 #endif /* __MACH_TEGRA_USB_MODEM_POWER_H */