diff options
author | Magnus Damm <damm@igel.co.jp> | 2009-08-19 05:50:49 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-08-19 21:30:11 -0400 |
commit | d2e27bdf2870e507dd4abba1f56ca84ee6ae7232 (patch) | |
tree | 9452f67c644907bdaab59d663b3e91dc74c611b1 /drivers | |
parent | c41442474a26984abaa094e96e42182868eab658 (diff) |
usb: add clock support to r8a66597 gadget driver
Add support for the clock framework to the r8a66597 gadget driver.
This is needed to control the clock driving the USB block.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/r8a66597-udc.c | 37 | ||||
-rw-r--r-- | drivers/usb/gadget/r8a66597-udc.h | 7 |
2 files changed, 41 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 | ||
1486 | static int __init r8a66597_probe(struct platform_device *pdev) | 1493 | static 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 | ||
1597 | clean_up2: | 1621 | clean_up3: |
1598 | free_irq(irq, r8a66597); | 1622 | free_irq(irq, r8a66597); |
1623 | clean_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 | ||
1599 | clean_up: | 1630 | clean_up: |
1600 | if (r8a66597) { | 1631 | if (r8a66597) { |
1601 | if (r8a66597->ep0_req) | 1632 | if (r8a66597->ep0_req) |
diff --git a/drivers/usb/gadget/r8a66597-udc.h b/drivers/usb/gadget/r8a66597-udc.h index a2464bf337c8..7d9a325e7b6d 100644 --- a/drivers/usb/gadget/r8a66597-udc.h +++ b/drivers/usb/gadget/r8a66597-udc.h | |||
@@ -23,6 +23,10 @@ | |||
23 | #ifndef __R8A66597_H__ | 23 | #ifndef __R8A66597_H__ |
24 | #define __R8A66597_H__ | 24 | #define __R8A66597_H__ |
25 | 25 | ||
26 | #ifdef CONFIG_HAVE_CLK | ||
27 | #include <linux/clk.h> | ||
28 | #endif | ||
29 | |||
26 | #include <linux/usb/r8a66597.h> | 30 | #include <linux/usb/r8a66597.h> |
27 | 31 | ||
28 | #define R8A66597_MAX_SAMPLING 10 | 32 | #define R8A66597_MAX_SAMPLING 10 |
@@ -88,6 +92,9 @@ struct r8a66597 { | |||
88 | spinlock_t lock; | 92 | spinlock_t lock; |
89 | unsigned long reg; | 93 | unsigned long reg; |
90 | 94 | ||
95 | #ifdef CONFIG_HAVE_CLK | ||
96 | struct clk *clk; | ||
97 | #endif | ||
91 | struct r8a66597_platdata *pdata; | 98 | struct r8a66597_platdata *pdata; |
92 | 99 | ||
93 | struct usb_gadget gadget; | 100 | struct usb_gadget gadget; |