]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
ARM: tegra: support modem EDP request/threshold updates
authorNeil Patel <neilp@nvidia.com>
Thu, 21 Feb 2013 19:16:07 +0000 (14:16 -0500)
committerDan Willemsen <dwillemsen@nvidia.com>
Sat, 14 Sep 2013 20:00:24 +0000 (13:00 -0700)
The modem client unregisters and re-registers during crash recovery.
Since permissions are set at init we need use sysfs files for request
and threshold updates that are present at boot.

Bug 1242282

Change-Id: I5023eb39f78224a7022dafd9af2ab753b1449952
Signed-off-by: Neil Patel <neilp@nvidia.com>
Reviewed-on: http://git-master/r/203017
Reviewed-by: Mrutyunjay Sawant <msawant@nvidia.com>
Tested-by: Mrutyunjay Sawant <msawant@nvidia.com>
arch/arm/mach-tegra/tegra_bbc_proxy.c
arch/arm/mach-tegra/tegra_usb_modem_power.c

index 98533aa2e2f6e72e146b5f61adfbe78c9421c253..a05fa1d6274a1258175bb0d238ee63b5b3064c27 100644 (file)
@@ -173,11 +173,65 @@ done:
 }
 static DEVICE_ATTR(i_max, S_IRUSR | S_IWUSR, i_max_show, i_max_store);
 
+static ssize_t request_store(struct device *pdev, struct device_attribute *attr,
+                            const char *buff, size_t size)
+{
+       struct tegra_bbc_proxy *bbc = dev_get_drvdata(pdev);
+       struct edp_client *c;
+       unsigned int id;
+       int ret;
+
+       if (sscanf(buff, "%u", &id) != 1)
+               return -EINVAL;
+
+       if (!bbc->edp_client_registered)
+               return -EINVAL;
+
+       c = &bbc->modem_edp_client;
+       if (id >= c->num_states)
+               return -EINVAL;
+
+       ret = edp_update_client_request(c, id, NULL);
+       if (ret)
+               dev_err(pdev, "state update to %u failed\n", id);
+       else
+               ret = size;
+
+       return ret;
+}
+static DEVICE_ATTR(request, S_IWUSR, NULL, request_store);
+
+static ssize_t threshold_store(struct device *pdev,
+                              struct device_attribute *attr,
+                              const char *buff, size_t size)
+{
+       struct tegra_bbc_proxy *bbc = dev_get_drvdata(pdev);
+       unsigned int tv;
+       int ret;
+
+       if (sscanf(buff, "%u", &tv) != 1)
+               return -EINVAL;
+
+       if (!bbc->edp_client_registered)
+               return -EINVAL;
+
+       ret = edp_update_loan_threshold(&bbc->modem_edp_client, tv);
+       if (ret)
+               dev_err(pdev, "threshold update to %u failed\n", tv);
+       else
+               ret = size;
+
+       return ret;
+}
+DEVICE_ATTR(threshold, S_IWUSR, NULL, threshold_store);
+
 static struct device_attribute *edp_attributes[] = {
        &dev_attr_i_breach_ppm,
        &dev_attr_i_thresh_3g_adjperiod,
        &dev_attr_i_thresh_lte_adjperiod,
        &dev_attr_i_max,
+       &dev_attr_request,
+       &dev_attr_threshold,
        NULL
 };
 
index 030b9a123740961ff537908cd550ee5d01844815..84c89f385a22b6fe33a393c68cb1bc184efa5c3c 100644 (file)
@@ -629,11 +629,65 @@ done:
 }
 static DEVICE_ATTR(i_max, S_IRUSR | S_IWUSR, i_max_show, i_max_store);
 
+static ssize_t request_store(struct device *pdev, struct device_attribute *attr,
+                            const char *buff, size_t size)
+{
+       struct tegra_usb_modem *modem = dev_get_drvdata(pdev);
+       struct edp_client *c;
+       unsigned int id;
+       int ret;
+
+       if (sscanf(buff, "%u", &id) != 1)
+               return -EINVAL;
+
+       if (!modem->edp_client_registered)
+               return -EINVAL;
+
+       c = &modem->modem_edp_client;
+       if (id >= c->num_states)
+               return -EINVAL;
+
+       ret = edp_update_client_request(c, id, NULL);
+       if (ret)
+               dev_err(pdev, "state update to %u failed\n", id);
+       else
+               ret = size;
+
+       return ret;
+}
+static DEVICE_ATTR(request, S_IWUSR, NULL, request_store);
+
+static ssize_t threshold_store(struct device *pdev,
+                              struct device_attribute *attr,
+                              const char *buff, size_t size)
+{
+       struct tegra_usb_modem *modem = dev_get_drvdata(pdev);
+       unsigned int tv;
+       int ret;
+
+       if (sscanf(buff, "%u", &tv) != 1)
+               return -EINVAL;
+
+       if (!modem->edp_client_registered)
+               return -EINVAL;
+
+       ret = edp_update_loan_threshold(&modem->modem_edp_client, tv);
+       if (ret)
+               dev_err(pdev, "threshold update to %u failed\n", tv);
+       else
+               ret = size;
+
+       return ret;
+}
+DEVICE_ATTR(threshold, S_IWUSR, NULL, threshold_store);
+
 static struct device_attribute *edp_attributes[] = {
        &dev_attr_i_breach_ppm,
        &dev_attr_i_thresh_3g_adjperiod,
        &dev_attr_i_thresh_lte_adjperiod,
        &dev_attr_i_max,
+       &dev_attr_request,
+       &dev_attr_threshold,
        NULL
 };