diff mbox

[2/3] DSPBRIDGE: Implement sysfs entry to enable/disable wdt3

Message ID 496565EC904933469F292DDA3F1663E602A6A218FA@dlee06.ent.ti.com (mailing list archive)
State Awaiting Upstream, archived
Headers show

Commit Message

Guzman Lugo, Fernando Nov. 11, 2009, 6:57 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/dsp/bridge/rmgr/drv_interface.c b/drivers/dsp/bridge/rmgr/drv_interface.c
index 65ac1e7..e9cd647 100755
--- a/drivers/dsp/bridge/rmgr/drv_interface.c
+++ b/drivers/dsp/bridge/rmgr/drv_interface.c
@@ -130,6 +130,9 @@  static s32 shm_size = 0x500000;	/* 5 MB */
 static u32 phys_mempool_base;
 static u32 phys_mempool_size;
 static int tc_wordswapon;	/* Default value is always false */
+#ifdef CONFIG_BRIDGE_WDT3
+extern u32 wtd3_enable;
+#endif
 
 /* Minimum ACTIVE VDD1 OPP level for reliable DSP operation */
 unsigned short min_active_opp = 3;
@@ -680,7 +683,7 @@  DSP_STATUS DRV_RemoveAllResources(HANDLE hPCtxt)
 /*
  * sysfs
  */
-static ssize_t drv_state_show(struct kobject *kobj, struct kobj_attribute *attr,
+static ssize_t drv_state_show(struct device *dev, struct device_attribute *attr,
                         char *buf)
 {
 	struct WMD_DEV_CONTEXT *dwContext;
@@ -701,11 +704,63 @@  static ssize_t drv_state_show(struct kobject *kobj, struct kobj_attribute *attr,
         return sprintf(buf, "%d\n", drv_state);
 }
 
-static struct kobj_attribute drv_state_attr = __ATTR_RO(drv_state);
+static DEVICE_ATTR(drv_state, S_IRUGO, drv_state_show, NULL);
+
+#ifdef CONFIG_BRIDGE_WDT3
+static ssize_t wdt3_show(struct device *dev, struct device_attribute *attr,
+							char *buf)
+{
+	return sprintf(buf, "%d\n", wtd3_enable);
+}
+
+static ssize_t wdt3_store(struct device *dev, struct device_attribute *attr,
+					const char *buf, size_t n)
+{
+	u32 wdt3;
+	struct DEV_OBJECT *dev_object;
+	struct WMD_DEV_CONTEXT *dev_ctxt;
+
+	if (sscanf(buf, "%d", &wdt3) != 1)
+		return -EINVAL;
+
+	dev_object = DEV_GetFirst();
+	if (!dev_object)
+		goto func_end;
+	DEV_GetWMDContext(dev_object, &dev_ctxt);
+	if (!dev_ctxt)
+		goto func_end;
+
+	/* enable WDT */
+	if (wdt3 == 1) {
+		if (wtd3_enable)
+			goto func_end;
+		if (!CLK_Get_UseCnt(SERVICESCLK_wdt3_fck) &&
+				dev_ctxt->dwBrdState != BRD_DSP_HIBERNATION &&
+				DSP_FAILED(dsp_wdt_config(WDT3_ENABLE))) {
+			pr_err("Error enabling WDT3\n");
+			goto func_end;
+		}
+		wtd3_enable = 1;
+	} else if (!wdt3) {
+		if (!wtd3_enable)
+			goto func_end;
+		if (CLK_Get_UseCnt(SERVICESCLK_wdt3_fck))
+			dsp_wdt_config(WDT3_DISABLE);
+		wtd3_enable = 0;
+	}
+func_end:
+	return n;
+}
+
+static DEVICE_ATTR(wdt3_enable, S_IWUSR | S_IRUGO, wdt3_show, wdt3_store);
+#endif
 
 static struct attribute *attrs[] = {
-        &drv_state_attr.attr,
-        NULL,
+	&dev_attr_drv_state.attr,
+#ifdef CONFIG_BRIDGE_WDT3
+	&dev_attr_wdt3_enable.attr,
+#endif
+	NULL,
 };
 
 static struct attribute_group attr_group = {