aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/r8a66597-udc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/r8a66597-udc.c')
-rw-r--r--drivers/usb/gadget/r8a66597-udc.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c
index cc0ba68efa55..c65753ffe0f0 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -25,6 +25,7 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/clk.h>
28 29
29#include <linux/usb/ch9.h> 30#include <linux/usb/ch9.h>
30#include <linux/usb/gadget.h> 31#include <linux/usb/gadget.h>
@@ -1475,6 +1476,12 @@ static int __exit r8a66597_remove(struct platform_device *pdev)
1475 iounmap((void *)r8a66597->reg); 1476 iounmap((void *)r8a66597->reg);
1476 free_irq(platform_get_irq(pdev, 0), r8a66597); 1477 free_irq(platform_get_irq(pdev, 0), r8a66597);
1477 r8a66597_free_request(&r8a66597->ep[0].ep, r8a66597->ep0_req); 1478 r8a66597_free_request(&r8a66597->ep[0].ep, r8a66597->ep0_req);
1479#ifdef CONFIG_HAVE_CLK
1480 if (r8a66597->pdata->on_chip) {
1481 clk_disable(r8a66597->clk);
1482 clk_put(r8a66597->clk);
1483 }
1484#endif
1478 kfree(r8a66597); 1485 kfree(r8a66597);
1479 return 0; 1486 return 0;
1480} 1487}
@@ -1485,6 +1492,9 @@ static void nop_completion(struct usb_ep *ep, struct usb_request *r)
1485 1492
1486static int __init r8a66597_probe(struct platform_device *pdev) 1493static int __init r8a66597_probe(struct platform_device *pdev)
1487{ 1494{
1495#ifdef CONFIG_HAVE_CLK
1496 char clk_name[8];
1497#endif
1488 struct resource *res, *ires; 1498 struct resource *res, *ires;
1489 int irq; 1499 int irq;
1490 void __iomem *reg = NULL; 1500 void __iomem *reg = NULL;
@@ -1545,13 +1555,27 @@ static int __init r8a66597_probe(struct platform_device *pdev)
1545 1555
1546 r8a66597->bi_bufnum = R8A66597_BASE_BUFNUM; 1556 r8a66597->bi_bufnum = R8A66597_BASE_BUFNUM;
1547 1557
1558#ifdef CONFIG_HAVE_CLK
1559 if (r8a66597->pdata->on_chip) {
1560 snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id);
1561 r8a66597->clk = clk_get(&pdev->dev, clk_name);
1562 if (IS_ERR(r8a66597->clk)) {
1563 dev_err(&pdev->dev, "cannot get clock \"%s\"\n",
1564 clk_name);
1565 ret = PTR_ERR(r8a66597->clk);
1566 goto clean_up;
1567 }
1568 clk_enable(r8a66597->clk);
1569 }
1570#endif
1571
1548 disable_controller(r8a66597); /* make sure controller is disabled */ 1572 disable_controller(r8a66597); /* make sure controller is disabled */
1549 1573
1550 ret = request_irq(irq, r8a66597_irq, IRQF_DISABLED | IRQF_SHARED, 1574 ret = request_irq(irq, r8a66597_irq, IRQF_DISABLED | IRQF_SHARED,
1551 udc_name, r8a66597); 1575 udc_name, r8a66597);
1552 if (ret < 0) { 1576 if (ret < 0) {
1553 printk(KERN_ERR "request_irq error (%d)\n", ret); 1577 printk(KERN_ERR "request_irq error (%d)\n", ret);
1554 goto clean_up; 1578 goto clean_up2;
1555 } 1579 }
1556 1580
1557 INIT_LIST_HEAD(&r8a66597->gadget.ep_list); 1581 INIT_LIST_HEAD(&r8a66597->gadget.ep_list);
@@ -1586,7 +1610,7 @@ static int __init r8a66597_probe(struct platform_device *pdev)
1586 r8a66597->ep0_req = r8a66597_alloc_request(&r8a66597->ep[0].ep, 1610 r8a66597->ep0_req = r8a66597_alloc_request(&r8a66597->ep[0].ep,
1587 GFP_KERNEL); 1611 GFP_KERNEL);
1588 if (r8a66597->ep0_req == NULL) 1612 if (r8a66597->ep0_req == NULL)
1589 goto clean_up2; 1613 goto clean_up3;
1590 r8a66597->ep0_req->complete = nop_completion; 1614 r8a66597->ep0_req->complete = nop_completion;
1591 1615
1592 init_controller(r8a66597); 1616 init_controller(r8a66597);
@@ -1594,8 +1618,15 @@ static int __init r8a66597_probe(struct platform_device *pdev)
1594 dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION); 1618 dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION);
1595 return 0; 1619 return 0;
1596 1620
1597clean_up2: 1621clean_up3:
1598 free_irq(irq, r8a66597); 1622 free_irq(irq, r8a66597);
1623clean_up2:
1624#ifdef CONFIG_HAVE_CLK
1625 if (r8a66597->pdata->on_chip) {
1626 clk_disable(r8a66597->clk);
1627 clk_put(r8a66597->clk);
1628 }
1629#endif
1599clean_up: 1630clean_up:
1600 if (r8a66597) { 1631 if (r8a66597) {
1601 if (r8a66597->ep0_req) 1632 if (r8a66597->ep0_req)