From 35e55c5e0e5454504cc887c1fb4b6f5fd41b54c0 Mon Sep 17 00:00:00 2001 From: lyz Date: Wed, 29 Oct 2014 08:57:18 +0800 Subject: [PATCH] usb: ehci: add attribute to start usb eye-pattern test --- drivers/usb/host/ehci-rockchip.c | 47 ++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/ehci-rockchip.c b/drivers/usb/host/ehci-rockchip.c index 207d6f5301f8..5157a0bf6dd4 100755 --- a/drivers/usb/host/ehci-rockchip.c +++ b/drivers/usb/host/ehci-rockchip.c @@ -289,6 +289,41 @@ static ssize_t debug_show(struct device *_dev, struct device_attribute *attr, static DEVICE_ATTR(debug_ehci, S_IRUGO, debug_show, NULL); +static int test_sq(struct ehci_hcd *ehci) +{ + u32 portc = readl(&ehci->regs->port_status); + + if ((portc & PORT_PE) && !(portc & PORT_SUSPEND)) { + portc &= ~PORT_RWC_BITS; + portc |= PORT_TEST_PKT; + writel(portc, &ehci->regs->port_status); + EHCI_PRINT("Start packet test\n"); + return 0; + + } else + EHCI_PRINT("Invalid connect status PORTC = 0x%08x\n", portc); + + return -1; +} + +static ssize_t test_sq_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) + +{ + struct rkehci_platform_data *pldata = dev->platform_data; + struct ehci_hcd *ehci = hcd_to_ehci(dev_get_drvdata(dev)); + + if (pldata->phy_status == USB_PHY_SUSPEND) { + EHCI_PRINT("Invalid status : SUSPEND\n"); + return -EBUSY; + } + + return (test_sq(ehci)) ? -EBUSY : count; +} + +static DEVICE_ATTR(test_sq, S_IWUSR, NULL, test_sq_store); + static struct of_device_id rk_ehci_of_match[] = { { .compatible = "rockchip,rk3288_rk_ehci_host", @@ -307,7 +342,6 @@ static int ehci_rk_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct rkehci_platform_data *pldata; int ret; - int retval = 0; static u64 usb_dmamask = 0xffffffffUL; struct device_node *node = pdev->dev.of_node; struct rkehci_pdata_id *p; @@ -335,8 +369,10 @@ static int ehci_rk_probe(struct platform_device *pdev) dev->dma_mask = &usb_dmamask; - retval = device_create_file(dev, &dev_attr_ehci_power); - retval = device_create_file(dev, &dev_attr_debug_ehci); + device_create_file(dev, &dev_attr_ehci_power); + device_create_file(dev, &dev_attr_debug_ehci); + device_create_file(dev, &dev_attr_test_sq); + hcd = usb_create_hcd(&rk_ehci_hc_driver, &pdev->dev, dev_name(&pdev->dev)); @@ -446,6 +482,11 @@ put_hcd: static int ehci_rk_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); + struct device *dev = &pdev->dev; + + device_remove_file(dev, &dev_attr_ehci_power); + device_remove_file(dev, &dev_attr_debug_ehci); + device_remove_file(dev, &dev_attr_test_sq); usb_put_hcd(hcd); -- 2.34.1