提交 719a72b7 编写于 作者: M Magnus Damm 提交者: Paul Mundt

usb: r8a66597-hcd platform data on_chip support

Convert the r8a66597-hcd driver to use the on_chip flag
from platform data to enable on chip behaviour instead
of relying on CONFIG_SUPERH_ON_CHIP_R8A66597 ugliness.

This makes the code cleaner and also allows us to support
both external and internal r8a66597 with the same kernel.

It also makes the Kconfig part more future proof since
we with this patch can add support for new processors
with on-chip r8a66597 without modifying the Kconfig.
Signed-off-by: NMagnus Damm <damm@igel.co.jp>
Signed-off-by: NPaul Mundt <lethal@linux-sh.org>
上级 ae1cef6e
...@@ -304,6 +304,7 @@ static struct platform_device sh_eth_device = { ...@@ -304,6 +304,7 @@ static struct platform_device sh_eth_device = {
}; };
static struct r8a66597_platdata sh7724_usb0_host_data = { static struct r8a66597_platdata sh7724_usb0_host_data = {
.on_chip = 1,
}; };
static struct resource sh7724_usb0_host_resources[] = { static struct resource sh7724_usb0_host_resources[] = {
......
...@@ -40,7 +40,7 @@ static struct platform_device iic_device = { ...@@ -40,7 +40,7 @@ static struct platform_device iic_device = {
}; };
static struct r8a66597_platdata r8a66597_data = { static struct r8a66597_platdata r8a66597_data = {
/* This set zero to all members */ .on_chip = 1,
}; };
static struct resource usb_host_resources[] = { static struct resource usb_host_resources[] = {
......
...@@ -398,7 +398,7 @@ static struct platform_device rtc_device = { ...@@ -398,7 +398,7 @@ static struct platform_device rtc_device = {
}; };
static struct r8a66597_platdata r8a66597_data = { static struct r8a66597_platdata r8a66597_data = {
/* This set zero to all members */ .on_chip = 1,
}; };
static struct resource sh7723_usb_host_resources[] = { static struct resource sh7723_usb_host_resources[] = {
......
...@@ -336,13 +336,6 @@ config USB_R8A66597_HCD ...@@ -336,13 +336,6 @@ config USB_R8A66597_HCD
To compile this driver as a module, choose M here: the To compile this driver as a module, choose M here: the
module will be called r8a66597-hcd. module will be called r8a66597-hcd.
config SUPERH_ON_CHIP_R8A66597
boolean "Enable SuperH on-chip R8A66597 USB"
depends on USB_R8A66597_HCD && (CPU_SUBTYPE_SH7366 || CPU_SUBTYPE_SH7723 || CPU_SUBTYPE_SH7724)
help
This driver enables support for the on-chip R8A66597 in the
SH7366, SH7723 and SH7724 processors.
config USB_WHCI_HCD config USB_WHCI_HCD
tristate "Wireless USB Host Controller Interface (WHCI) driver (EXPERIMENTAL)" tristate "Wireless USB Host Controller Interface (WHCI) driver (EXPERIMENTAL)"
depends on EXPERIMENTAL depends on EXPERIMENTAL
......
...@@ -91,43 +91,43 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) ...@@ -91,43 +91,43 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597)
u16 tmp; u16 tmp;
int i = 0; int i = 0;
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) if (r8a66597->pdata->on_chip) {
#if defined(CONFIG_HAVE_CLK) #ifdef CONFIG_HAVE_CLK
clk_enable(r8a66597->clk); clk_enable(r8a66597->clk);
#endif #endif
do { do {
r8a66597_write(r8a66597, SCKE, SYSCFG0); r8a66597_write(r8a66597, SCKE, SYSCFG0);
tmp = r8a66597_read(r8a66597, SYSCFG0); tmp = r8a66597_read(r8a66597, SYSCFG0);
if (i++ > 1000) { if (i++ > 1000) {
printk(KERN_ERR "r8a66597: register access fail.\n"); printk(KERN_ERR "r8a66597: reg access fail.\n");
return -ENXIO; return -ENXIO;
} }
} while ((tmp & SCKE) != SCKE); } while ((tmp & SCKE) != SCKE);
r8a66597_write(r8a66597, 0x04, 0x02); r8a66597_write(r8a66597, 0x04, 0x02);
#else } else {
do { do {
r8a66597_write(r8a66597, USBE, SYSCFG0); r8a66597_write(r8a66597, USBE, SYSCFG0);
tmp = r8a66597_read(r8a66597, SYSCFG0); tmp = r8a66597_read(r8a66597, SYSCFG0);
if (i++ > 1000) { if (i++ > 1000) {
printk(KERN_ERR "r8a66597: register access fail.\n"); printk(KERN_ERR "r8a66597: reg access fail.\n");
return -ENXIO; return -ENXIO;
} }
} while ((tmp & USBE) != USBE); } while ((tmp & USBE) != USBE);
r8a66597_bclr(r8a66597, USBE, SYSCFG0); r8a66597_bclr(r8a66597, USBE, SYSCFG0);
r8a66597_mdfy(r8a66597, get_xtal_from_pdata(r8a66597->pdata), XTAL, r8a66597_mdfy(r8a66597, get_xtal_from_pdata(r8a66597->pdata),
SYSCFG0); XTAL, SYSCFG0);
i = 0; i = 0;
r8a66597_bset(r8a66597, XCKE, SYSCFG0); r8a66597_bset(r8a66597, XCKE, SYSCFG0);
do { do {
msleep(1); msleep(1);
tmp = r8a66597_read(r8a66597, SYSCFG0); tmp = r8a66597_read(r8a66597, SYSCFG0);
if (i++ > 500) { if (i++ > 500) {
printk(KERN_ERR "r8a66597: register access fail.\n"); printk(KERN_ERR "r8a66597: reg access fail.\n");
return -ENXIO; return -ENXIO;
} }
} while ((tmp & SCKE) != SCKE); } while ((tmp & SCKE) != SCKE);
#endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */ }
return 0; return 0;
} }
...@@ -136,15 +136,16 @@ static void r8a66597_clock_disable(struct r8a66597 *r8a66597) ...@@ -136,15 +136,16 @@ static void r8a66597_clock_disable(struct r8a66597 *r8a66597)
{ {
r8a66597_bclr(r8a66597, SCKE, SYSCFG0); r8a66597_bclr(r8a66597, SCKE, SYSCFG0);
udelay(1); udelay(1);
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
#if defined(CONFIG_HAVE_CLK) if (r8a66597->pdata->on_chip) {
clk_disable(r8a66597->clk); #ifdef CONFIG_HAVE_CLK
#endif clk_disable(r8a66597->clk);
#else
r8a66597_bclr(r8a66597, PLLC, SYSCFG0);
r8a66597_bclr(r8a66597, XCKE, SYSCFG0);
r8a66597_bclr(r8a66597, USBE, SYSCFG0);
#endif #endif
} else {
r8a66597_bclr(r8a66597, PLLC, SYSCFG0);
r8a66597_bclr(r8a66597, XCKE, SYSCFG0);
r8a66597_bclr(r8a66597, USBE, SYSCFG0);
}
} }
static void r8a66597_enable_port(struct r8a66597 *r8a66597, int port) static void r8a66597_enable_port(struct r8a66597 *r8a66597, int port)
...@@ -205,7 +206,7 @@ static int enable_controller(struct r8a66597 *r8a66597) ...@@ -205,7 +206,7 @@ static int enable_controller(struct r8a66597 *r8a66597)
r8a66597_bset(r8a66597, SIGNE | SACKE, INTENB1); r8a66597_bset(r8a66597, SIGNE | SACKE, INTENB1);
for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) for (port = 0; port < r8a66597->max_root_hub; port++)
r8a66597_enable_port(r8a66597, port); r8a66597_enable_port(r8a66597, port);
return 0; return 0;
...@@ -218,7 +219,7 @@ static void disable_controller(struct r8a66597 *r8a66597) ...@@ -218,7 +219,7 @@ static void disable_controller(struct r8a66597 *r8a66597)
r8a66597_write(r8a66597, 0, INTENB0); r8a66597_write(r8a66597, 0, INTENB0);
r8a66597_write(r8a66597, 0, INTSTS0); r8a66597_write(r8a66597, 0, INTSTS0);
for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) for (port = 0; port < r8a66597->max_root_hub; port++)
r8a66597_disable_port(r8a66597, port); r8a66597_disable_port(r8a66597, port);
r8a66597_clock_disable(r8a66597); r8a66597_clock_disable(r8a66597);
...@@ -249,11 +250,12 @@ static int is_hub_limit(char *devpath) ...@@ -249,11 +250,12 @@ static int is_hub_limit(char *devpath)
return ((strlen(devpath) >= 4) ? 1 : 0); return ((strlen(devpath) >= 4) ? 1 : 0);
} }
static void get_port_number(char *devpath, u16 *root_port, u16 *hub_port) static void get_port_number(struct r8a66597 *r8a66597,
char *devpath, u16 *root_port, u16 *hub_port)
{ {
if (root_port) { if (root_port) {
*root_port = (devpath[0] & 0x0F) - 1; *root_port = (devpath[0] & 0x0F) - 1;
if (*root_port >= R8A66597_MAX_ROOT_HUB) if (*root_port >= r8a66597->max_root_hub)
printk(KERN_ERR "r8a66597: Illegal root port number.\n"); printk(KERN_ERR "r8a66597: Illegal root port number.\n");
} }
if (hub_port) if (hub_port)
...@@ -355,7 +357,8 @@ static int make_r8a66597_device(struct r8a66597 *r8a66597, ...@@ -355,7 +357,8 @@ static int make_r8a66597_device(struct r8a66597 *r8a66597,
INIT_LIST_HEAD(&dev->device_list); INIT_LIST_HEAD(&dev->device_list);
list_add_tail(&dev->device_list, &r8a66597->child_device); list_add_tail(&dev->device_list, &r8a66597->child_device);
get_port_number(urb->dev->devpath, &dev->root_port, &dev->hub_port); get_port_number(r8a66597, urb->dev->devpath,
&dev->root_port, &dev->hub_port);
if (!is_child_device(urb->dev->devpath)) if (!is_child_device(urb->dev->devpath))
r8a66597->root_hub[dev->root_port].dev = dev; r8a66597->root_hub[dev->root_port].dev = dev;
...@@ -420,7 +423,7 @@ static void free_usb_address(struct r8a66597 *r8a66597, ...@@ -420,7 +423,7 @@ static void free_usb_address(struct r8a66597 *r8a66597,
list_del(&dev->device_list); list_del(&dev->device_list);
kfree(dev); kfree(dev);
for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { for (port = 0; port < r8a66597->max_root_hub; port++) {
if (r8a66597->root_hub[port].dev == dev) { if (r8a66597->root_hub[port].dev == dev) {
r8a66597->root_hub[port].dev = NULL; r8a66597->root_hub[port].dev = NULL;
break; break;
...@@ -495,10 +498,20 @@ static void r8a66597_pipe_toggle(struct r8a66597 *r8a66597, ...@@ -495,10 +498,20 @@ static void r8a66597_pipe_toggle(struct r8a66597 *r8a66597,
r8a66597_bset(r8a66597, SQCLR, pipe->pipectr); r8a66597_bset(r8a66597, SQCLR, pipe->pipectr);
} }
static inline unsigned short mbw_value(struct r8a66597 *r8a66597)
{
if (r8a66597->pdata->on_chip)
return MBW_32;
else
return MBW_16;
}
/* this function must be called with interrupt disabled */ /* this function must be called with interrupt disabled */
static inline void cfifo_change(struct r8a66597 *r8a66597, u16 pipenum) static inline void cfifo_change(struct r8a66597 *r8a66597, u16 pipenum)
{ {
r8a66597_mdfy(r8a66597, MBW | pipenum, MBW | CURPIPE, CFIFOSEL); unsigned short mbw = mbw_value(r8a66597);
r8a66597_mdfy(r8a66597, mbw | pipenum, mbw | CURPIPE, CFIFOSEL);
r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, pipenum); r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, pipenum);
} }
...@@ -506,11 +519,13 @@ static inline void cfifo_change(struct r8a66597 *r8a66597, u16 pipenum) ...@@ -506,11 +519,13 @@ static inline void cfifo_change(struct r8a66597 *r8a66597, u16 pipenum)
static inline void fifo_change_from_pipe(struct r8a66597 *r8a66597, static inline void fifo_change_from_pipe(struct r8a66597 *r8a66597,
struct r8a66597_pipe *pipe) struct r8a66597_pipe *pipe)
{ {
unsigned short mbw = mbw_value(r8a66597);
cfifo_change(r8a66597, 0); cfifo_change(r8a66597, 0);
r8a66597_mdfy(r8a66597, MBW | 0, MBW | CURPIPE, D0FIFOSEL); r8a66597_mdfy(r8a66597, mbw | 0, mbw | CURPIPE, D0FIFOSEL);
r8a66597_mdfy(r8a66597, MBW | 0, MBW | CURPIPE, D1FIFOSEL); r8a66597_mdfy(r8a66597, mbw | 0, mbw | CURPIPE, D1FIFOSEL);
r8a66597_mdfy(r8a66597, MBW | pipe->info.pipenum, MBW | CURPIPE, r8a66597_mdfy(r8a66597, mbw | pipe->info.pipenum, mbw | CURPIPE,
pipe->fifosel); pipe->fifosel);
r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, pipe->info.pipenum); r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, pipe->info.pipenum);
} }
...@@ -742,9 +757,13 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, ...@@ -742,9 +757,13 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597,
struct r8a66597_pipe *pipe, struct r8a66597_pipe *pipe,
struct urb *urb) struct urb *urb)
{ {
#if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
int i; int i;
struct r8a66597_pipe_info *info = &pipe->info; struct r8a66597_pipe_info *info = &pipe->info;
unsigned short mbw = mbw_value(r8a66597);
/* pipe dma is only for external controlles */
if (r8a66597->pdata->on_chip)
return;
if ((pipe->info.pipenum != 0) && (info->type != R8A66597_INT)) { if ((pipe->info.pipenum != 0) && (info->type != R8A66597_INT)) {
for (i = 0; i < R8A66597_MAX_DMA_CHANNEL; i++) { for (i = 0; i < R8A66597_MAX_DMA_CHANNEL; i++) {
...@@ -763,8 +782,8 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, ...@@ -763,8 +782,8 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597,
set_pipe_reg_addr(pipe, i); set_pipe_reg_addr(pipe, i);
cfifo_change(r8a66597, 0); cfifo_change(r8a66597, 0);
r8a66597_mdfy(r8a66597, MBW | pipe->info.pipenum, r8a66597_mdfy(r8a66597, mbw | pipe->info.pipenum,
MBW | CURPIPE, pipe->fifosel); mbw | CURPIPE, pipe->fifosel);
r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE,
pipe->info.pipenum); pipe->info.pipenum);
...@@ -772,7 +791,6 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, ...@@ -772,7 +791,6 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597,
break; break;
} }
} }
#endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */
} }
/* this function must be called with interrupt disabled */ /* this function must be called with interrupt disabled */
...@@ -1769,7 +1787,7 @@ static void r8a66597_timer(unsigned long _r8a66597) ...@@ -1769,7 +1787,7 @@ static void r8a66597_timer(unsigned long _r8a66597)
spin_lock_irqsave(&r8a66597->lock, flags); spin_lock_irqsave(&r8a66597->lock, flags);
for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) for (port = 0; port < r8a66597->max_root_hub; port++)
r8a66597_root_hub_control(r8a66597, port); r8a66597_root_hub_control(r8a66597, port);
spin_unlock_irqrestore(&r8a66597->lock, flags); spin_unlock_irqrestore(&r8a66597->lock, flags);
...@@ -1807,7 +1825,7 @@ static void set_address_zero(struct r8a66597 *r8a66597, struct urb *urb) ...@@ -1807,7 +1825,7 @@ static void set_address_zero(struct r8a66597 *r8a66597, struct urb *urb)
u16 root_port, hub_port; u16 root_port, hub_port;
if (usb_address == 0) { if (usb_address == 0) {
get_port_number(urb->dev->devpath, get_port_number(r8a66597, urb->dev->devpath,
&root_port, &hub_port); &root_port, &hub_port);
set_devadd_reg(r8a66597, 0, set_devadd_reg(r8a66597, 0,
get_r8a66597_usb_speed(urb->dev->speed), get_r8a66597_usb_speed(urb->dev->speed),
...@@ -2082,7 +2100,7 @@ static int r8a66597_hub_status_data(struct usb_hcd *hcd, char *buf) ...@@ -2082,7 +2100,7 @@ static int r8a66597_hub_status_data(struct usb_hcd *hcd, char *buf)
*buf = 0; /* initialize (no change) */ *buf = 0; /* initialize (no change) */
for (i = 0; i < R8A66597_MAX_ROOT_HUB; i++) { for (i = 0; i < r8a66597->max_root_hub; i++) {
if (r8a66597->root_hub[i].port & 0xffff0000) if (r8a66597->root_hub[i].port & 0xffff0000)
*buf |= 1 << (i + 1); *buf |= 1 << (i + 1);
} }
...@@ -2097,11 +2115,11 @@ static void r8a66597_hub_descriptor(struct r8a66597 *r8a66597, ...@@ -2097,11 +2115,11 @@ static void r8a66597_hub_descriptor(struct r8a66597 *r8a66597,
{ {
desc->bDescriptorType = 0x29; desc->bDescriptorType = 0x29;
desc->bHubContrCurrent = 0; desc->bHubContrCurrent = 0;
desc->bNbrPorts = R8A66597_MAX_ROOT_HUB; desc->bNbrPorts = r8a66597->max_root_hub;
desc->bDescLength = 9; desc->bDescLength = 9;
desc->bPwrOn2PwrGood = 0; desc->bPwrOn2PwrGood = 0;
desc->wHubCharacteristics = cpu_to_le16(0x0011); desc->wHubCharacteristics = cpu_to_le16(0x0011);
desc->bitmap[0] = ((1 << R8A66597_MAX_ROOT_HUB) - 1) << 1; desc->bitmap[0] = ((1 << r8a66597->max_root_hub) - 1) << 1;
desc->bitmap[1] = ~0; desc->bitmap[1] = ~0;
} }
...@@ -2129,7 +2147,7 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -2129,7 +2147,7 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
} }
break; break;
case ClearPortFeature: case ClearPortFeature:
if (wIndex > R8A66597_MAX_ROOT_HUB) if (wIndex > r8a66597->max_root_hub)
goto error; goto error;
if (wLength != 0) if (wLength != 0)
goto error; goto error;
...@@ -2162,12 +2180,12 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, ...@@ -2162,12 +2180,12 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
*buf = 0x00; *buf = 0x00;
break; break;
case GetPortStatus: case GetPortStatus:
if (wIndex > R8A66597_MAX_ROOT_HUB) if (wIndex > r8a66597->max_root_hub)
goto error; goto error;
*(__le32 *)buf = cpu_to_le32(rh->port); *(__le32 *)buf = cpu_to_le32(rh->port);
break; break;
case SetPortFeature: case SetPortFeature:
if (wIndex > R8A66597_MAX_ROOT_HUB) if (wIndex > r8a66597->max_root_hub)
goto error; goto error;
if (wLength != 0) if (wLength != 0)
goto error; goto error;
...@@ -2216,7 +2234,7 @@ static int r8a66597_bus_suspend(struct usb_hcd *hcd) ...@@ -2216,7 +2234,7 @@ static int r8a66597_bus_suspend(struct usb_hcd *hcd)
dbg("%s", __func__); dbg("%s", __func__);
for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { for (port = 0; port < r8a66597->max_root_hub; port++) {
struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; struct r8a66597_root_hub *rh = &r8a66597->root_hub[port];
unsigned long dvstctr_reg = get_dvstctr_reg(port); unsigned long dvstctr_reg = get_dvstctr_reg(port);
...@@ -2247,7 +2265,7 @@ static int r8a66597_bus_resume(struct usb_hcd *hcd) ...@@ -2247,7 +2265,7 @@ static int r8a66597_bus_resume(struct usb_hcd *hcd)
dbg("%s", __func__); dbg("%s", __func__);
for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { for (port = 0; port < r8a66597->max_root_hub; port++) {
struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; struct r8a66597_root_hub *rh = &r8a66597->root_hub[port];
unsigned long dvstctr_reg = get_dvstctr_reg(port); unsigned long dvstctr_reg = get_dvstctr_reg(port);
...@@ -2314,7 +2332,7 @@ static int r8a66597_suspend(struct device *dev) ...@@ -2314,7 +2332,7 @@ static int r8a66597_suspend(struct device *dev)
disable_controller(r8a66597); disable_controller(r8a66597);
for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { for (port = 0; port < r8a66597->max_root_hub; port++) {
struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; struct r8a66597_root_hub *rh = &r8a66597->root_hub[port];
rh->port = 0x00000000; rh->port = 0x00000000;
...@@ -2354,8 +2372,9 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) ...@@ -2354,8 +2372,9 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev)
del_timer_sync(&r8a66597->rh_timer); del_timer_sync(&r8a66597->rh_timer);
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
iounmap((void *)r8a66597->reg); iounmap((void *)r8a66597->reg);
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) #ifdef CONFIG_HAVE_CLK
clk_put(r8a66597->clk); if (r8a66597->pdata->on_chip)
clk_put(r8a66597->clk);
#endif #endif
usb_put_hcd(hcd); usb_put_hcd(hcd);
return 0; return 0;
...@@ -2363,7 +2382,7 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) ...@@ -2363,7 +2382,7 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev)
static int __devinit r8a66597_probe(struct platform_device *pdev) static int __devinit r8a66597_probe(struct platform_device *pdev)
{ {
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) #ifdef CONFIG_HAVE_CLK
char clk_name[8]; char clk_name[8];
#endif #endif
struct resource *res = NULL, *ires; struct resource *res = NULL, *ires;
...@@ -2425,15 +2444,20 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) ...@@ -2425,15 +2444,20 @@ static int __devinit r8a66597_probe(struct platform_device *pdev)
r8a66597->pdata = pdev->dev.platform_data; r8a66597->pdata = pdev->dev.platform_data;
r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW;
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) if (r8a66597->pdata->on_chip) {
snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); #ifdef CONFIG_HAVE_CLK
r8a66597->clk = clk_get(&pdev->dev, clk_name); snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id);
if (IS_ERR(r8a66597->clk)) { r8a66597->clk = clk_get(&pdev->dev, clk_name);
dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); if (IS_ERR(r8a66597->clk)) {
ret = PTR_ERR(r8a66597->clk); dev_err(&pdev->dev, "cannot get clock \"%s\"\n",
goto clean_up2; clk_name);
} ret = PTR_ERR(r8a66597->clk);
goto clean_up2;
}
#endif #endif
r8a66597->max_root_hub = 1;
} else
r8a66597->max_root_hub = 2;
spin_lock_init(&r8a66597->lock); spin_lock_init(&r8a66597->lock);
init_timer(&r8a66597->rh_timer); init_timer(&r8a66597->rh_timer);
...@@ -2463,8 +2487,9 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) ...@@ -2463,8 +2487,9 @@ static int __devinit r8a66597_probe(struct platform_device *pdev)
return 0; return 0;
clean_up3: clean_up3:
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) #ifdef CONFIG_HAVE_CLK
clk_put(r8a66597->clk); if (r8a66597->pdata->on_chip)
clk_put(r8a66597->clk);
clean_up2: clean_up2:
#endif #endif
usb_put_hcd(hcd); usb_put_hcd(hcd);
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#ifndef __R8A66597_H__ #ifndef __R8A66597_H__
#define __R8A66597_H__ #define __R8A66597_H__
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) #ifdef CONFIG_HAVE_CLK
#include <linux/clk.h> #include <linux/clk.h>
#endif #endif
...@@ -193,13 +193,9 @@ ...@@ -193,13 +193,9 @@
#define REW 0x4000 /* b14: Buffer rewind */ #define REW 0x4000 /* b14: Buffer rewind */
#define DCLRM 0x2000 /* b13: DMA buffer clear mode */ #define DCLRM 0x2000 /* b13: DMA buffer clear mode */
#define DREQE 0x1000 /* b12: DREQ output enable */ #define DREQE 0x1000 /* b12: DREQ output enable */
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
#define MBW 0x0800
#else
#define MBW 0x0400 /* b10: Maximum bit width for FIFO access */
#endif
#define MBW_8 0x0000 /* 8bit */ #define MBW_8 0x0000 /* 8bit */
#define MBW_16 0x0400 /* 16bit */ #define MBW_16 0x0400 /* 16bit */
#define MBW_32 0x0800 /* 32bit */
#define BIGEND 0x0100 /* b8: Big endian mode */ #define BIGEND 0x0100 /* b8: Big endian mode */
#define BYTE_LITTLE 0x0000 /* little dendian */ #define BYTE_LITTLE 0x0000 /* little dendian */
#define BYTE_BIG 0x0100 /* big endifan */ #define BYTE_BIG 0x0100 /* big endifan */
...@@ -405,11 +401,7 @@ ...@@ -405,11 +401,7 @@
#define R8A66597_MAX_NUM_PIPE 10 #define R8A66597_MAX_NUM_PIPE 10
#define R8A66597_BUF_BSIZE 8 #define R8A66597_BUF_BSIZE 8
#define R8A66597_MAX_DEVICE 10 #define R8A66597_MAX_DEVICE 10
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
#define R8A66597_MAX_ROOT_HUB 1
#else
#define R8A66597_MAX_ROOT_HUB 2 #define R8A66597_MAX_ROOT_HUB 2
#endif
#define R8A66597_MAX_SAMPLING 5 #define R8A66597_MAX_SAMPLING 5
#define R8A66597_RH_POLL_TIME 10 #define R8A66597_RH_POLL_TIME 10
#define R8A66597_MAX_DMA_CHANNEL 2 #define R8A66597_MAX_DMA_CHANNEL 2
...@@ -487,7 +479,7 @@ struct r8a66597_root_hub { ...@@ -487,7 +479,7 @@ struct r8a66597_root_hub {
struct r8a66597 { struct r8a66597 {
spinlock_t lock; spinlock_t lock;
unsigned long reg; unsigned long reg;
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) #ifdef CONFIG_HAVE_CLK
struct clk *clk; struct clk *clk;
#endif #endif
struct r8a66597_platdata *pdata; struct r8a66597_platdata *pdata;
...@@ -504,6 +496,7 @@ struct r8a66597 { ...@@ -504,6 +496,7 @@ struct r8a66597 {
unsigned short interval_map; unsigned short interval_map;
unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE]; unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE];
unsigned char dma_map; unsigned char dma_map;
unsigned int max_root_hub;
struct list_head child_device; struct list_head child_device;
unsigned long child_connect_map[4]; unsigned long child_connect_map[4];
...@@ -550,21 +543,22 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597, ...@@ -550,21 +543,22 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597,
unsigned long offset, u16 *buf, unsigned long offset, u16 *buf,
int len) int len)
{ {
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
unsigned long fifoaddr = r8a66597->reg + offset; unsigned long fifoaddr = r8a66597->reg + offset;
unsigned long count; unsigned long count;
count = len / 4; if (r8a66597->pdata->on_chip) {
insl(fifoaddr, buf, count); count = len / 4;
insl(fifoaddr, buf, count);
if (len & 0x00000003) { if (len & 0x00000003) {
unsigned long tmp = inl(fifoaddr); unsigned long tmp = inl(fifoaddr);
memcpy((unsigned char *)buf + count * 4, &tmp, len & 0x03); memcpy((unsigned char *)buf + count * 4, &tmp,
len & 0x03);
}
} else {
len = (len + 1) / 2;
insw(fifoaddr, buf, len);
} }
#else
len = (len + 1) / 2;
insw(r8a66597->reg + offset, buf, len);
#endif
} }
static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val, static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val,
...@@ -578,33 +572,33 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, ...@@ -578,33 +572,33 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,
int len) int len)
{ {
unsigned long fifoaddr = r8a66597->reg + offset; unsigned long fifoaddr = r8a66597->reg + offset;
#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597)
unsigned long count; unsigned long count;
unsigned char *pb; unsigned char *pb;
int i; int i;
count = len / 4; if (r8a66597->pdata->on_chip) {
outsl(fifoaddr, buf, count); count = len / 4;
outsl(fifoaddr, buf, count);
if (len & 0x00000003) {
pb = (unsigned char *)buf + count * 4;
for (i = 0; i < (len & 0x00000003); i++) {
if (r8a66597_read(r8a66597, CFIFOSEL) & BIGEND)
outb(pb[i], fifoaddr + i);
else
outb(pb[i], fifoaddr + 3 - i);
}
}
} else {
int odd = len & 0x0001;
if (len & 0x00000003) { len = len / 2;
pb = (unsigned char *)buf + count * 4; outsw(fifoaddr, buf, len);
for (i = 0; i < (len & 0x00000003); i++) { if (unlikely(odd)) {
if (r8a66597_read(r8a66597, CFIFOSEL) & BIGEND) buf = &buf[len];
outb(pb[i], fifoaddr + i); outb((unsigned char)*buf, fifoaddr);
else
outb(pb[i], fifoaddr + 3 - i);
} }
} }
#else
int odd = len & 0x0001;
len = len / 2;
outsw(fifoaddr, buf, len);
if (unlikely(odd)) {
buf = &buf[len];
outb((unsigned char)*buf, fifoaddr);
}
#endif
} }
static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, static inline void r8a66597_mdfy(struct r8a66597 *r8a66597,
......
...@@ -31,6 +31,9 @@ struct r8a66597_platdata { ...@@ -31,6 +31,9 @@ struct r8a66597_platdata {
/* This ops can controll port power instead of DVSTCTR register. */ /* This ops can controll port power instead of DVSTCTR register. */
void (*port_power)(int port, int power); void (*port_power)(int port, int power);
/* set one = on chip controller, set zero = external controller */
unsigned on_chip:1;
/* (external controller only) set R8A66597_PLATDATA_XTAL_nnMHZ */ /* (external controller only) set R8A66597_PLATDATA_XTAL_nnMHZ */
unsigned xtal:2; unsigned xtal:2;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册