Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 120048
b: refs/heads/master
c: af5be79
h: refs/heads/master
v: v3
  • Loading branch information
Magnus Damm authored and Paul Mundt committed Dec 22, 2008
1 parent 029bcbc commit 1a88a48
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a42b6dd69cb1c61c5f5a24061a227c22071786de
refs/heads/master: af5be79a7f8d7067588dc2863d37f7cd22e5f2de
3 changes: 1 addition & 2 deletions trunk/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static struct resource usbf_resources[] = {

static struct platform_device usbf_device = {
.name = "m66592_udc",
.id = -1,
.id = 0, /* "usbf0" clock */
.dev = {
.dma_mask = NULL,
.coherent_dma_mask = 0xffffffff,
Expand Down Expand Up @@ -198,7 +198,6 @@ static int __init sh7722_devices_setup(void)
clk_always_enable("mstp026"); /* XYMEM */
clk_always_enable("mstp022"); /* INTC */
clk_always_enable("mstp020"); /* SuperHyway */
clk_always_enable("mstp211"); /* USB */
clk_always_enable("mstp202"); /* VEU */
clk_always_enable("mstp201"); /* VPU */

Expand Down
34 changes: 25 additions & 9 deletions trunk/drivers/usb/gadget/m66592-udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,6 @@ static void start_ep0(struct m66592_ep *ep, struct m66592_request *req)
#if defined(CONFIG_SUPERH_BUILT_IN_M66592)
static void init_controller(struct m66592 *m66592)
{
usbf_start_clock();
m66592_bset(m66592, M66592_HSE, M66592_SYSCFG); /* High spd */
m66592_bclr(m66592, M66592_USBE, M66592_SYSCFG);
m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG);
Expand Down Expand Up @@ -671,9 +670,7 @@ static void init_controller(struct m66592 *m66592)

static void disable_controller(struct m66592 *m66592)
{
#if defined(CONFIG_SUPERH_BUILT_IN_M66592)
usbf_stop_clock();
#else
#if !defined(CONFIG_SUPERH_BUILT_IN_M66592)
m66592_bclr(m66592, M66592_SCKE, M66592_SYSCFG);
udelay(1);
m66592_bclr(m66592, M66592_PLLC, M66592_SYSCFG);
Expand All @@ -686,9 +683,7 @@ static void disable_controller(struct m66592 *m66592)

static void m66592_start_xclock(struct m66592 *m66592)
{
#if defined(CONFIG_SUPERH_BUILT_IN_M66592)
usbf_start_clock();
#else
#if !defined(CONFIG_SUPERH_BUILT_IN_M66592)
u16 tmp;

tmp = m66592_read(m66592, M66592_SYSCFG);
Expand Down Expand Up @@ -1539,7 +1534,10 @@ static int __exit m66592_remove(struct platform_device *pdev)
iounmap(m66592->reg);
free_irq(platform_get_irq(pdev, 0), m66592);
m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);
usbf_stop_clock();
#if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK)
clk_disable(m66592->clk);
clk_put(m66592->clk);
#endif
kfree(m66592);
return 0;
}
Expand All @@ -1556,6 +1554,9 @@ static int __init m66592_probe(struct platform_device *pdev)
int irq;
void __iomem *reg = NULL;
struct m66592 *m66592 = NULL;
#if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK)
char clk_name[8];
#endif
int ret = 0;
int i;

Expand Down Expand Up @@ -1614,6 +1615,16 @@ static int __init m66592_probe(struct platform_device *pdev)
goto clean_up;
}

#if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK)
snprintf(clk_name, sizeof(clk_name), "usbf%d", pdev->id);
m66592->clk = clk_get(&pdev->dev, clk_name);
if (IS_ERR(m66592->clk)) {
dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name);
ret = PTR_ERR(m66592->clk);
goto clean_up2;
}
clk_enable(m66592->clk);
#endif
INIT_LIST_HEAD(&m66592->gadget.ep_list);
m66592->gadget.ep0 = &m66592->ep[0].ep;
INIT_LIST_HEAD(&m66592->gadget.ep0->ep_list);
Expand Down Expand Up @@ -1645,14 +1656,19 @@ static int __init m66592_probe(struct platform_device *pdev)

m66592->ep0_req = m66592_alloc_request(&m66592->ep[0].ep, GFP_KERNEL);
if (m66592->ep0_req == NULL)
goto clean_up2;
goto clean_up3;
m66592->ep0_req->complete = nop_completion;

init_controller(m66592);

dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION);
return 0;

clean_up3:
#if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK)
clk_disable(m66592->clk);
clk_put(m66592->clk);
#endif
clean_up2:
free_irq(irq, m66592);
clean_up:
Expand Down
27 changes: 7 additions & 20 deletions trunk/drivers/usb/gadget/m66592-udc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#ifndef __M66592_UDC_H__
#define __M66592_UDC_H__

#if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK)
#include <linux/clk.h>
#endif

#define M66592_SYSCFG 0x00
#define M66592_XTAL 0xC000 /* b15-14: Crystal selection */
#define M66592_XTAL48 0x8000 /* 48MHz */
Expand Down Expand Up @@ -476,6 +480,9 @@ struct m66592_ep {
struct m66592 {
spinlock_t lock;
void __iomem *reg;
#if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK)
struct clk *clk;
#endif

struct usb_gadget gadget;
struct usb_gadget_driver *driver;
Expand Down Expand Up @@ -604,26 +611,6 @@ static inline void m66592_mdfy(struct m66592 *m66592, u16 val, u16 pat,
#define m66592_bset(m66592, val, offset) \
m66592_mdfy(m66592, val, 0, offset)

#if defined(CONFIG_SUPERH_BUILT_IN_M66592)
#include <asm/io.h>
#define MSTPCR2 0xA4150038 /* for SH7722 */
#define MSTPCR2_USB 0x00000800

static inline void usbf_start_clock(void)
{
ctrl_outl(ctrl_inl(MSTPCR2) & ~MSTPCR2_USB, MSTPCR2);
}

static inline void usbf_stop_clock(void)
{
ctrl_outl(ctrl_inl(MSTPCR2) | MSTPCR2_USB, MSTPCR2);
}

#else
#define usbf_start_clock(x)
#define usbf_stop_clock(x)
#endif /* if defined(CONFIG_SUPERH_BUILT_IN_M66592) */

#endif /* ifndef __M66592_UDC_H__ */


0 comments on commit 1a88a48

Please sign in to comment.