aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Damm <damm@igel.co.jp>2008-10-31 07:22:13 -0400
committerPaul Mundt <lethal@linux-sh.org>2008-12-22 04:42:51 -0500
commitaf5be79a7f8d7067588dc2863d37f7cd22e5f2de (patch)
treeb667ec42b98479669ed8e81f27b093672e9897b1
parenta42b6dd69cb1c61c5f5a24061a227c22071786de (diff)
sh: sh_mobile usbf clock framework support
Add clock framework support to the usbf/m66592 driver and adjust the cpu specific code accordingly. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7722.c3
-rw-r--r--drivers/usb/gadget/m66592-udc.c34
-rw-r--r--drivers/usb/gadget/m66592-udc.h27
3 files changed, 33 insertions, 31 deletions
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
index 786eaf1cf4c3..4953e74f9193 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
@@ -62,7 +62,7 @@ static struct resource usbf_resources[] = {
62 62
63static struct platform_device usbf_device = { 63static struct platform_device usbf_device = {
64 .name = "m66592_udc", 64 .name = "m66592_udc",
65 .id = -1, 65 .id = 0, /* "usbf0" clock */
66 .dev = { 66 .dev = {
67 .dma_mask = NULL, 67 .dma_mask = NULL,
68 .coherent_dma_mask = 0xffffffff, 68 .coherent_dma_mask = 0xffffffff,
@@ -198,7 +198,6 @@ static int __init sh7722_devices_setup(void)
198 clk_always_enable("mstp026"); /* XYMEM */ 198 clk_always_enable("mstp026"); /* XYMEM */
199 clk_always_enable("mstp022"); /* INTC */ 199 clk_always_enable("mstp022"); /* INTC */
200 clk_always_enable("mstp020"); /* SuperHyway */ 200 clk_always_enable("mstp020"); /* SuperHyway */
201 clk_always_enable("mstp211"); /* USB */
202 clk_always_enable("mstp202"); /* VEU */ 201 clk_always_enable("mstp202"); /* VEU */
203 clk_always_enable("mstp201"); /* VPU */ 202 clk_always_enable("mstp201"); /* VPU */
204 203
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c
index 77b44fb48f0a..201c67b625cc 100644
--- a/drivers/usb/gadget/m66592-udc.c
+++ b/drivers/usb/gadget/m66592-udc.c
@@ -623,7 +623,6 @@ static void start_ep0(struct m66592_ep *ep, struct m66592_request *req)
623#if defined(CONFIG_SUPERH_BUILT_IN_M66592) 623#if defined(CONFIG_SUPERH_BUILT_IN_M66592)
624static void init_controller(struct m66592 *m66592) 624static void init_controller(struct m66592 *m66592)
625{ 625{
626 usbf_start_clock();
627 m66592_bset(m66592, M66592_HSE, M66592_SYSCFG); /* High spd */ 626 m66592_bset(m66592, M66592_HSE, M66592_SYSCFG); /* High spd */
628 m66592_bclr(m66592, M66592_USBE, M66592_SYSCFG); 627 m66592_bclr(m66592, M66592_USBE, M66592_SYSCFG);
629 m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG); 628 m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG);
@@ -671,9 +670,7 @@ static void init_controller(struct m66592 *m66592)
671 670
672static void disable_controller(struct m66592 *m66592) 671static void disable_controller(struct m66592 *m66592)
673{ 672{
674#if defined(CONFIG_SUPERH_BUILT_IN_M66592) 673#if !defined(CONFIG_SUPERH_BUILT_IN_M66592)
675 usbf_stop_clock();
676#else
677 m66592_bclr(m66592, M66592_SCKE, M66592_SYSCFG); 674 m66592_bclr(m66592, M66592_SCKE, M66592_SYSCFG);
678 udelay(1); 675 udelay(1);
679 m66592_bclr(m66592, M66592_PLLC, M66592_SYSCFG); 676 m66592_bclr(m66592, M66592_PLLC, M66592_SYSCFG);
@@ -686,9 +683,7 @@ static void disable_controller(struct m66592 *m66592)
686 683
687static void m66592_start_xclock(struct m66592 *m66592) 684static void m66592_start_xclock(struct m66592 *m66592)
688{ 685{
689#if defined(CONFIG_SUPERH_BUILT_IN_M66592) 686#if !defined(CONFIG_SUPERH_BUILT_IN_M66592)
690 usbf_start_clock();
691#else
692 u16 tmp; 687 u16 tmp;
693 688
694 tmp = m66592_read(m66592, M66592_SYSCFG); 689 tmp = m66592_read(m66592, M66592_SYSCFG);
@@ -1539,7 +1534,10 @@ static int __exit m66592_remove(struct platform_device *pdev)
1539 iounmap(m66592->reg); 1534 iounmap(m66592->reg);
1540 free_irq(platform_get_irq(pdev, 0), m66592); 1535 free_irq(platform_get_irq(pdev, 0), m66592);
1541 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); 1536 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);
1542 usbf_stop_clock(); 1537#if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK)
1538 clk_disable(m66592->clk);
1539 clk_put(m66592->clk);
1540#endif
1543 kfree(m66592); 1541 kfree(m66592);
1544 return 0; 1542 return 0;
1545} 1543}
@@ -1556,6 +1554,9 @@ static int __init m66592_probe(struct platform_device *pdev)
1556 int irq; 1554 int irq;
1557 void __iomem *reg = NULL; 1555 void __iomem *reg = NULL;
1558 struct m66592 *m66592 = NULL; 1556 struct m66592 *m66592 = NULL;
1557#if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK)
1558 char clk_name[8];
1559#endif
1559 int ret = 0; 1560 int ret = 0;
1560 int i; 1561 int i;
1561 1562
@@ -1614,6 +1615,16 @@ static int __init m66592_probe(struct platform_device *pdev)
1614 goto clean_up; 1615 goto clean_up;
1615 } 1616 }
1616 1617
1618#if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK)
1619 snprintf(clk_name, sizeof(clk_name), "usbf%d", pdev->id);
1620 m66592->clk = clk_get(&pdev->dev, clk_name);
1621 if (IS_ERR(m66592->clk)) {
1622 dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name);
1623 ret = PTR_ERR(m66592->clk);
1624 goto clean_up2;
1625 }
1626 clk_enable(m66592->clk);
1627#endif
1617 INIT_LIST_HEAD(&m66592->gadget.ep_list); 1628 INIT_LIST_HEAD(&m66592->gadget.ep_list);
1618 m66592->gadget.ep0 = &m66592->ep[0].ep; 1629 m66592->gadget.ep0 = &m66592->ep[0].ep;
1619 INIT_LIST_HEAD(&m66592->gadget.ep0->ep_list); 1630 INIT_LIST_HEAD(&m66592->gadget.ep0->ep_list);
@@ -1645,7 +1656,7 @@ static int __init m66592_probe(struct platform_device *pdev)
1645 1656
1646 m66592->ep0_req = m66592_alloc_request(&m66592->ep[0].ep, GFP_KERNEL); 1657 m66592->ep0_req = m66592_alloc_request(&m66592->ep[0].ep, GFP_KERNEL);
1647 if (m66592->ep0_req == NULL) 1658 if (m66592->ep0_req == NULL)
1648 goto clean_up2; 1659 goto clean_up3;
1649 m66592->ep0_req->complete = nop_completion; 1660 m66592->ep0_req->complete = nop_completion;
1650 1661
1651 init_controller(m66592); 1662 init_controller(m66592);
@@ -1653,6 +1664,11 @@ static int __init m66592_probe(struct platform_device *pdev)
1653 dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION); 1664 dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION);
1654 return 0; 1665 return 0;
1655 1666
1667clean_up3:
1668#if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK)
1669 clk_disable(m66592->clk);
1670 clk_put(m66592->clk);
1671#endif
1656clean_up2: 1672clean_up2:
1657 free_irq(irq, m66592); 1673 free_irq(irq, m66592);
1658clean_up: 1674clean_up:
diff --git a/drivers/usb/gadget/m66592-udc.h b/drivers/usb/gadget/m66592-udc.h
index f118f00f1466..286ce07e7960 100644
--- a/drivers/usb/gadget/m66592-udc.h
+++ b/drivers/usb/gadget/m66592-udc.h
@@ -23,6 +23,10 @@
23#ifndef __M66592_UDC_H__ 23#ifndef __M66592_UDC_H__
24#define __M66592_UDC_H__ 24#define __M66592_UDC_H__
25 25
26#if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK)
27#include <linux/clk.h>
28#endif
29
26#define M66592_SYSCFG 0x00 30#define M66592_SYSCFG 0x00
27#define M66592_XTAL 0xC000 /* b15-14: Crystal selection */ 31#define M66592_XTAL 0xC000 /* b15-14: Crystal selection */
28#define M66592_XTAL48 0x8000 /* 48MHz */ 32#define M66592_XTAL48 0x8000 /* 48MHz */
@@ -476,6 +480,9 @@ struct m66592_ep {
476struct m66592 { 480struct m66592 {
477 spinlock_t lock; 481 spinlock_t lock;
478 void __iomem *reg; 482 void __iomem *reg;
483#if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK)
484 struct clk *clk;
485#endif
479 486
480 struct usb_gadget gadget; 487 struct usb_gadget gadget;
481 struct usb_gadget_driver *driver; 488 struct usb_gadget_driver *driver;
@@ -604,26 +611,6 @@ static inline void m66592_mdfy(struct m66592 *m66592, u16 val, u16 pat,
604#define m66592_bset(m66592, val, offset) \ 611#define m66592_bset(m66592, val, offset) \
605 m66592_mdfy(m66592, val, 0, offset) 612 m66592_mdfy(m66592, val, 0, offset)
606 613
607#if defined(CONFIG_SUPERH_BUILT_IN_M66592)
608#include <asm/io.h>
609#define MSTPCR2 0xA4150038 /* for SH7722 */
610#define MSTPCR2_USB 0x00000800
611
612static inline void usbf_start_clock(void)
613{
614 ctrl_outl(ctrl_inl(MSTPCR2) & ~MSTPCR2_USB, MSTPCR2);
615}
616
617static inline void usbf_stop_clock(void)
618{
619 ctrl_outl(ctrl_inl(MSTPCR2) | MSTPCR2_USB, MSTPCR2);
620}
621
622#else
623#define usbf_start_clock(x)
624#define usbf_stop_clock(x)
625#endif /* if defined(CONFIG_SUPERH_BUILT_IN_M66592) */
626
627#endif /* ifndef __M66592_UDC_H__ */ 614#endif /* ifndef __M66592_UDC_H__ */
628 615
629 616