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>
This commit is contained in:
parent
a42b6dd69c
commit
af5be79a7f
|
@ -62,7 +62,7 @@ static struct resource usbf_resources[] = {
|
||||||
|
|
||||||
static struct platform_device usbf_device = {
|
static struct platform_device usbf_device = {
|
||||||
.name = "m66592_udc",
|
.name = "m66592_udc",
|
||||||
.id = -1,
|
.id = 0, /* "usbf0" clock */
|
||||||
.dev = {
|
.dev = {
|
||||||
.dma_mask = NULL,
|
.dma_mask = NULL,
|
||||||
.coherent_dma_mask = 0xffffffff,
|
.coherent_dma_mask = 0xffffffff,
|
||||||
|
@ -198,7 +198,6 @@ static int __init sh7722_devices_setup(void)
|
||||||
clk_always_enable("mstp026"); /* XYMEM */
|
clk_always_enable("mstp026"); /* XYMEM */
|
||||||
clk_always_enable("mstp022"); /* INTC */
|
clk_always_enable("mstp022"); /* INTC */
|
||||||
clk_always_enable("mstp020"); /* SuperHyway */
|
clk_always_enable("mstp020"); /* SuperHyway */
|
||||||
clk_always_enable("mstp211"); /* USB */
|
|
||||||
clk_always_enable("mstp202"); /* VEU */
|
clk_always_enable("mstp202"); /* VEU */
|
||||||
clk_always_enable("mstp201"); /* VPU */
|
clk_always_enable("mstp201"); /* VPU */
|
||||||
|
|
||||||
|
|
|
@ -623,7 +623,6 @@ static void start_ep0(struct m66592_ep *ep, struct m66592_request *req)
|
||||||
#if defined(CONFIG_SUPERH_BUILT_IN_M66592)
|
#if defined(CONFIG_SUPERH_BUILT_IN_M66592)
|
||||||
static void init_controller(struct m66592 *m66592)
|
static void init_controller(struct m66592 *m66592)
|
||||||
{
|
{
|
||||||
usbf_start_clock();
|
|
||||||
m66592_bset(m66592, M66592_HSE, M66592_SYSCFG); /* High spd */
|
m66592_bset(m66592, M66592_HSE, M66592_SYSCFG); /* High spd */
|
||||||
m66592_bclr(m66592, M66592_USBE, M66592_SYSCFG);
|
m66592_bclr(m66592, M66592_USBE, M66592_SYSCFG);
|
||||||
m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG);
|
m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG);
|
||||||
|
@ -671,9 +670,7 @@ static void init_controller(struct m66592 *m66592)
|
||||||
|
|
||||||
static void disable_controller(struct m66592 *m66592)
|
static void disable_controller(struct m66592 *m66592)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_SUPERH_BUILT_IN_M66592)
|
#if !defined(CONFIG_SUPERH_BUILT_IN_M66592)
|
||||||
usbf_stop_clock();
|
|
||||||
#else
|
|
||||||
m66592_bclr(m66592, M66592_SCKE, M66592_SYSCFG);
|
m66592_bclr(m66592, M66592_SCKE, M66592_SYSCFG);
|
||||||
udelay(1);
|
udelay(1);
|
||||||
m66592_bclr(m66592, M66592_PLLC, M66592_SYSCFG);
|
m66592_bclr(m66592, M66592_PLLC, M66592_SYSCFG);
|
||||||
|
@ -686,9 +683,7 @@ static void disable_controller(struct m66592 *m66592)
|
||||||
|
|
||||||
static void m66592_start_xclock(struct m66592 *m66592)
|
static void m66592_start_xclock(struct m66592 *m66592)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_SUPERH_BUILT_IN_M66592)
|
#if !defined(CONFIG_SUPERH_BUILT_IN_M66592)
|
||||||
usbf_start_clock();
|
|
||||||
#else
|
|
||||||
u16 tmp;
|
u16 tmp;
|
||||||
|
|
||||||
tmp = m66592_read(m66592, M66592_SYSCFG);
|
tmp = m66592_read(m66592, M66592_SYSCFG);
|
||||||
|
@ -1539,7 +1534,10 @@ static int __exit m66592_remove(struct platform_device *pdev)
|
||||||
iounmap(m66592->reg);
|
iounmap(m66592->reg);
|
||||||
free_irq(platform_get_irq(pdev, 0), m66592);
|
free_irq(platform_get_irq(pdev, 0), m66592);
|
||||||
m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);
|
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);
|
kfree(m66592);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1556,6 +1554,9 @@ static int __init m66592_probe(struct platform_device *pdev)
|
||||||
int irq;
|
int irq;
|
||||||
void __iomem *reg = NULL;
|
void __iomem *reg = NULL;
|
||||||
struct m66592 *m66592 = 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 ret = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -1614,6 +1615,16 @@ static int __init m66592_probe(struct platform_device *pdev)
|
||||||
goto clean_up;
|
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);
|
INIT_LIST_HEAD(&m66592->gadget.ep_list);
|
||||||
m66592->gadget.ep0 = &m66592->ep[0].ep;
|
m66592->gadget.ep0 = &m66592->ep[0].ep;
|
||||||
INIT_LIST_HEAD(&m66592->gadget.ep0->ep_list);
|
INIT_LIST_HEAD(&m66592->gadget.ep0->ep_list);
|
||||||
|
@ -1645,7 +1656,7 @@ static int __init m66592_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
m66592->ep0_req = m66592_alloc_request(&m66592->ep[0].ep, GFP_KERNEL);
|
m66592->ep0_req = m66592_alloc_request(&m66592->ep[0].ep, GFP_KERNEL);
|
||||||
if (m66592->ep0_req == NULL)
|
if (m66592->ep0_req == NULL)
|
||||||
goto clean_up2;
|
goto clean_up3;
|
||||||
m66592->ep0_req->complete = nop_completion;
|
m66592->ep0_req->complete = nop_completion;
|
||||||
|
|
||||||
init_controller(m66592);
|
init_controller(m66592);
|
||||||
|
@ -1653,6 +1664,11 @@ static int __init m66592_probe(struct platform_device *pdev)
|
||||||
dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION);
|
dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION);
|
||||||
return 0;
|
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:
|
clean_up2:
|
||||||
free_irq(irq, m66592);
|
free_irq(irq, m66592);
|
||||||
clean_up:
|
clean_up:
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
#ifndef __M66592_UDC_H__
|
#ifndef __M66592_UDC_H__
|
||||||
#define __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_SYSCFG 0x00
|
||||||
#define M66592_XTAL 0xC000 /* b15-14: Crystal selection */
|
#define M66592_XTAL 0xC000 /* b15-14: Crystal selection */
|
||||||
#define M66592_XTAL48 0x8000 /* 48MHz */
|
#define M66592_XTAL48 0x8000 /* 48MHz */
|
||||||
|
@ -476,6 +480,9 @@ struct m66592_ep {
|
||||||
struct m66592 {
|
struct m66592 {
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
void __iomem *reg;
|
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 gadget;
|
||||||
struct usb_gadget_driver *driver;
|
struct usb_gadget_driver *driver;
|
||||||
|
@ -604,26 +611,6 @@ static inline void m66592_mdfy(struct m66592 *m66592, u16 val, u16 pat,
|
||||||
#define m66592_bset(m66592, val, offset) \
|
#define m66592_bset(m66592, val, offset) \
|
||||||
m66592_mdfy(m66592, val, 0, 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__ */
|
#endif /* ifndef __M66592_UDC_H__ */
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue