aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel <pavel@ucw.cz>2018-10-28 16:05:29 +0100
committerPavel <pavel@ucw.cz>2019-01-07 11:30:39 +0100
commit696e83b17291bfdedadbd87caad4407b6ba8b5f2 (patch)
tree0f9c33a0ae758f686476460decfc6a9047aa6af6
parentb2d7a1e29b8129320bb82e27eb35183f2865ae57 (diff)
downloadlinux-k-696e83b17291bfdedadbd87caad4407b6ba8b5f2.tar.gz
n9?: twl4030 debugging hacks.
-rw-r--r--drivers/phy/ti/phy-twl4030-usb.c63
1 files changed, 55 insertions, 8 deletions
diff --git a/drivers/phy/ti/phy-twl4030-usb.c b/drivers/phy/ti/phy-twl4030-usb.c
index c267afb68f077c..9ecd14458a0e6e 100644
--- a/drivers/phy/ti/phy-twl4030-usb.c
+++ b/drivers/phy/ti/phy-twl4030-usb.c
@@ -500,7 +500,7 @@ static int twl4030_phy_power_on(struct phy *phy)
dev_dbg(twl->dev, "%s\n", __func__);
pm_runtime_get_sync(twl->dev);
- schedule_delayed_work(&twl->id_workaround_work, HZ);
+ schedule_delayed_work(&twl->id_workaround_work, 0);
pm_runtime_mark_last_busy(twl->dev);
pm_runtime_put_autosuspend(twl->dev);
@@ -571,6 +571,43 @@ static ssize_t twl4030_usb_vbus_show(struct device *dev,
}
static DEVICE_ATTR(vbus, 0444, twl4030_usb_vbus_show, NULL);
+static ssize_t twl4030_test_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct twl4030_usb *twl = dev_get_drvdata(dev);
+ int ret = -EINVAL;
+
+ mutex_lock(&twl->lock);
+ ret = sprintf(buf, "%s\n", "hello, world");
+ mutex_unlock(&twl->lock);
+
+ return ret;
+}
+
+static int twl4030_shutdown(struct twl4030_usb *twl);
+
+static ssize_t twl4030_test_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ unsigned long tmp;
+
+ struct twl4030_usb *twl = dev_get_drvdata(dev);
+
+ mutex_lock(&twl->lock);
+ sscanf(buf, "%lX", &tmp);
+ printk("TWL HACK: tmp = 0x%lX\n", tmp);
+ mutex_unlock(&twl->lock);
+
+ if (tmp == 0xdead) {
+ printk("TWL HACK: killing hardware\n");
+ printk("TWL HACK: killing hardware = %d\n", twl4030_shutdown(twl));
+ }
+
+ return strnlen(buf, count);
+}
+
+static DEVICE_ATTR(test, 0664, twl4030_test_show, twl4030_test_store);
+
static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
{
struct twl4030_usb *twl = _twl;
@@ -640,8 +677,7 @@ static int twl4030_phy_init(struct phy *phy)
struct twl4030_usb *twl = phy_get_drvdata(phy);
pm_runtime_get_sync(twl->dev);
- twl->linkstat = MUSB_UNKNOWN;
- schedule_delayed_work(&twl->id_workaround_work, HZ);
+ schedule_delayed_work(&twl->id_workaround_work, 0);
pm_runtime_mark_last_busy(twl->dev);
pm_runtime_put_autosuspend(twl->dev);
@@ -758,6 +794,9 @@ static int twl4030_usb_probe(struct platform_device *pdev)
if (device_create_file(&pdev->dev, &dev_attr_vbus))
dev_warn(&pdev->dev, "could not create sysfs file\n");
+ if (device_create_file(&pdev->dev, &dev_attr_test))
+ dev_warn(&pdev->dev, "could not create sysfs file #2\n");
+
ATOMIC_INIT_NOTIFIER_HEAD(&twl->phy.notifier);
pm_runtime_use_autosuspend(&pdev->dev);
@@ -794,15 +833,13 @@ static int twl4030_usb_probe(struct platform_device *pdev)
return 0;
}
-static int twl4030_usb_remove(struct platform_device *pdev)
+static int twl4030_shutdown(struct twl4030_usb *twl)
{
- struct twl4030_usb *twl = platform_get_drvdata(pdev);
int val;
usb_remove_phy(&twl->phy);
pm_runtime_get_sync(twl->dev);
cancel_delayed_work(&twl->id_workaround_work);
- device_remove_file(twl->dev, &dev_attr_vbus);
/* set transceiver mode to power on defaults */
twl4030_usb_set_mode(twl, -1);
@@ -811,8 +848,7 @@ static int twl4030_usb_remove(struct platform_device *pdev)
if (cable_present(twl->linkstat))
pm_runtime_put_noidle(twl->dev);
pm_runtime_mark_last_busy(twl->dev);
- pm_runtime_dont_use_autosuspend(&pdev->dev);
- pm_runtime_put_sync(twl->dev);
+ pm_runtime_put_sync_suspend(twl->dev);
pm_runtime_disable(twl->dev);
/* autogate 60MHz ULPI clock,
@@ -832,6 +868,17 @@ static int twl4030_usb_remove(struct platform_device *pdev)
return 0;
}
+
+static int twl4030_usb_remove(struct platform_device *pdev)
+{
+ struct twl4030_usb *twl = platform_get_drvdata(pdev);
+
+ device_remove_file(twl->dev, &dev_attr_vbus);
+ device_remove_file(twl->dev, &dev_attr_test);
+
+ return twl4030_shutdown(twl);
+}
+
#ifdef CONFIG_OF
static const struct of_device_id twl4030_usb_id_table[] = {
{ .compatible = "ti,twl4030-usb" },