diff options
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/host/Kconfig | 7 | ||||
-rw-r--r-- | drivers/usb/host/r8a66597-hcd.c | 187 | ||||
-rw-r--r-- | drivers/usb/host/r8a66597.h | 76 |
3 files changed, 141 insertions, 129 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 1a920c70b5a1..f21ca7d27a43 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -336,13 +336,6 @@ config USB_R8A66597_HCD | |||
336 | To compile this driver as a module, choose M here: the | 336 | To compile this driver as a module, choose M here: the |
337 | module will be called r8a66597-hcd. | 337 | module will be called r8a66597-hcd. |
338 | 338 | ||
339 | config SUPERH_ON_CHIP_R8A66597 | ||
340 | boolean "Enable SuperH on-chip R8A66597 USB" | ||
341 | depends on USB_R8A66597_HCD && (CPU_SUBTYPE_SH7366 || CPU_SUBTYPE_SH7723 || CPU_SUBTYPE_SH7724) | ||
342 | help | ||
343 | This driver enables support for the on-chip R8A66597 in the | ||
344 | SH7366, SH7723 and SH7724 processors. | ||
345 | |||
346 | config USB_WHCI_HCD | 339 | config USB_WHCI_HCD |
347 | tristate "Wireless USB Host Controller Interface (WHCI) driver (EXPERIMENTAL)" | 340 | tristate "Wireless USB Host Controller Interface (WHCI) driver (EXPERIMENTAL)" |
348 | depends on EXPERIMENTAL | 341 | depends on EXPERIMENTAL |
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index 09895a97c10b..82dce3e0d4d7 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -91,43 +91,43 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) | |||
91 | u16 tmp; | 91 | u16 tmp; |
92 | int i = 0; | 92 | int i = 0; |
93 | 93 | ||
94 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | 94 | if (r8a66597->pdata->on_chip) { |
95 | #if defined(CONFIG_HAVE_CLK) | 95 | #ifdef CONFIG_HAVE_CLK |
96 | clk_enable(r8a66597->clk); | 96 | clk_enable(r8a66597->clk); |
97 | #endif | 97 | #endif |
98 | do { | 98 | do { |
99 | r8a66597_write(r8a66597, SCKE, SYSCFG0); | 99 | r8a66597_write(r8a66597, SCKE, SYSCFG0); |
100 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 100 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
101 | if (i++ > 1000) { | 101 | if (i++ > 1000) { |
102 | printk(KERN_ERR "r8a66597: register access fail.\n"); | 102 | printk(KERN_ERR "r8a66597: reg access fail.\n"); |
103 | return -ENXIO; | 103 | return -ENXIO; |
104 | } | 104 | } |
105 | } while ((tmp & SCKE) != SCKE); | 105 | } while ((tmp & SCKE) != SCKE); |
106 | r8a66597_write(r8a66597, 0x04, 0x02); | 106 | r8a66597_write(r8a66597, 0x04, 0x02); |
107 | #else | 107 | } else { |
108 | do { | 108 | do { |
109 | r8a66597_write(r8a66597, USBE, SYSCFG0); | 109 | r8a66597_write(r8a66597, USBE, SYSCFG0); |
110 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 110 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
111 | if (i++ > 1000) { | 111 | if (i++ > 1000) { |
112 | printk(KERN_ERR "r8a66597: register access fail.\n"); | 112 | printk(KERN_ERR "r8a66597: reg access fail.\n"); |
113 | return -ENXIO; | 113 | return -ENXIO; |
114 | } | 114 | } |
115 | } while ((tmp & USBE) != USBE); | 115 | } while ((tmp & USBE) != USBE); |
116 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); | 116 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); |
117 | r8a66597_mdfy(r8a66597, get_xtal_from_pdata(r8a66597->pdata), XTAL, | 117 | r8a66597_mdfy(r8a66597, get_xtal_from_pdata(r8a66597->pdata), |
118 | SYSCFG0); | 118 | XTAL, SYSCFG0); |
119 | 119 | ||
120 | i = 0; | 120 | i = 0; |
121 | r8a66597_bset(r8a66597, XCKE, SYSCFG0); | 121 | r8a66597_bset(r8a66597, XCKE, SYSCFG0); |
122 | do { | 122 | do { |
123 | msleep(1); | 123 | msleep(1); |
124 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 124 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
125 | if (i++ > 500) { | 125 | if (i++ > 500) { |
126 | printk(KERN_ERR "r8a66597: register access fail.\n"); | 126 | printk(KERN_ERR "r8a66597: reg access fail.\n"); |
127 | return -ENXIO; | 127 | return -ENXIO; |
128 | } | 128 | } |
129 | } while ((tmp & SCKE) != SCKE); | 129 | } while ((tmp & SCKE) != SCKE); |
130 | #endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */ | 130 | } |
131 | 131 | ||
132 | return 0; | 132 | return 0; |
133 | } | 133 | } |
@@ -136,15 +136,16 @@ static void r8a66597_clock_disable(struct r8a66597 *r8a66597) | |||
136 | { | 136 | { |
137 | r8a66597_bclr(r8a66597, SCKE, SYSCFG0); | 137 | r8a66597_bclr(r8a66597, SCKE, SYSCFG0); |
138 | udelay(1); | 138 | udelay(1); |
139 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | 139 | |
140 | #if defined(CONFIG_HAVE_CLK) | 140 | if (r8a66597->pdata->on_chip) { |
141 | clk_disable(r8a66597->clk); | 141 | #ifdef CONFIG_HAVE_CLK |
142 | #endif | 142 | clk_disable(r8a66597->clk); |
143 | #else | ||
144 | r8a66597_bclr(r8a66597, PLLC, SYSCFG0); | ||
145 | r8a66597_bclr(r8a66597, XCKE, SYSCFG0); | ||
146 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); | ||
147 | #endif | 143 | #endif |
144 | } else { | ||
145 | r8a66597_bclr(r8a66597, PLLC, SYSCFG0); | ||
146 | r8a66597_bclr(r8a66597, XCKE, SYSCFG0); | ||
147 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); | ||
148 | } | ||
148 | } | 149 | } |
149 | 150 | ||
150 | static void r8a66597_enable_port(struct r8a66597 *r8a66597, int port) | 151 | static void r8a66597_enable_port(struct r8a66597 *r8a66597, int port) |
@@ -205,7 +206,7 @@ static int enable_controller(struct r8a66597 *r8a66597) | |||
205 | 206 | ||
206 | r8a66597_bset(r8a66597, SIGNE | SACKE, INTENB1); | 207 | r8a66597_bset(r8a66597, SIGNE | SACKE, INTENB1); |
207 | 208 | ||
208 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) | 209 | for (port = 0; port < r8a66597->max_root_hub; port++) |
209 | r8a66597_enable_port(r8a66597, port); | 210 | r8a66597_enable_port(r8a66597, port); |
210 | 211 | ||
211 | return 0; | 212 | return 0; |
@@ -218,7 +219,7 @@ static void disable_controller(struct r8a66597 *r8a66597) | |||
218 | r8a66597_write(r8a66597, 0, INTENB0); | 219 | r8a66597_write(r8a66597, 0, INTENB0); |
219 | r8a66597_write(r8a66597, 0, INTSTS0); | 220 | r8a66597_write(r8a66597, 0, INTSTS0); |
220 | 221 | ||
221 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) | 222 | for (port = 0; port < r8a66597->max_root_hub; port++) |
222 | r8a66597_disable_port(r8a66597, port); | 223 | r8a66597_disable_port(r8a66597, port); |
223 | 224 | ||
224 | r8a66597_clock_disable(r8a66597); | 225 | r8a66597_clock_disable(r8a66597); |
@@ -249,11 +250,12 @@ static int is_hub_limit(char *devpath) | |||
249 | return ((strlen(devpath) >= 4) ? 1 : 0); | 250 | return ((strlen(devpath) >= 4) ? 1 : 0); |
250 | } | 251 | } |
251 | 252 | ||
252 | static void get_port_number(char *devpath, u16 *root_port, u16 *hub_port) | 253 | static void get_port_number(struct r8a66597 *r8a66597, |
254 | char *devpath, u16 *root_port, u16 *hub_port) | ||
253 | { | 255 | { |
254 | if (root_port) { | 256 | if (root_port) { |
255 | *root_port = (devpath[0] & 0x0F) - 1; | 257 | *root_port = (devpath[0] & 0x0F) - 1; |
256 | if (*root_port >= R8A66597_MAX_ROOT_HUB) | 258 | if (*root_port >= r8a66597->max_root_hub) |
257 | printk(KERN_ERR "r8a66597: Illegal root port number.\n"); | 259 | printk(KERN_ERR "r8a66597: Illegal root port number.\n"); |
258 | } | 260 | } |
259 | if (hub_port) | 261 | if (hub_port) |
@@ -355,7 +357,8 @@ static int make_r8a66597_device(struct r8a66597 *r8a66597, | |||
355 | INIT_LIST_HEAD(&dev->device_list); | 357 | INIT_LIST_HEAD(&dev->device_list); |
356 | list_add_tail(&dev->device_list, &r8a66597->child_device); | 358 | list_add_tail(&dev->device_list, &r8a66597->child_device); |
357 | 359 | ||
358 | get_port_number(urb->dev->devpath, &dev->root_port, &dev->hub_port); | 360 | get_port_number(r8a66597, urb->dev->devpath, |
361 | &dev->root_port, &dev->hub_port); | ||
359 | if (!is_child_device(urb->dev->devpath)) | 362 | if (!is_child_device(urb->dev->devpath)) |
360 | r8a66597->root_hub[dev->root_port].dev = dev; | 363 | r8a66597->root_hub[dev->root_port].dev = dev; |
361 | 364 | ||
@@ -420,7 +423,7 @@ static void free_usb_address(struct r8a66597 *r8a66597, | |||
420 | list_del(&dev->device_list); | 423 | list_del(&dev->device_list); |
421 | kfree(dev); | 424 | kfree(dev); |
422 | 425 | ||
423 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { | 426 | for (port = 0; port < r8a66597->max_root_hub; port++) { |
424 | if (r8a66597->root_hub[port].dev == dev) { | 427 | if (r8a66597->root_hub[port].dev == dev) { |
425 | r8a66597->root_hub[port].dev = NULL; | 428 | r8a66597->root_hub[port].dev = NULL; |
426 | break; | 429 | break; |
@@ -495,10 +498,20 @@ static void r8a66597_pipe_toggle(struct r8a66597 *r8a66597, | |||
495 | r8a66597_bset(r8a66597, SQCLR, pipe->pipectr); | 498 | r8a66597_bset(r8a66597, SQCLR, pipe->pipectr); |
496 | } | 499 | } |
497 | 500 | ||
501 | static inline unsigned short mbw_value(struct r8a66597 *r8a66597) | ||
502 | { | ||
503 | if (r8a66597->pdata->on_chip) | ||
504 | return MBW_32; | ||
505 | else | ||
506 | return MBW_16; | ||
507 | } | ||
508 | |||
498 | /* this function must be called with interrupt disabled */ | 509 | /* this function must be called with interrupt disabled */ |
499 | static inline void cfifo_change(struct r8a66597 *r8a66597, u16 pipenum) | 510 | static inline void cfifo_change(struct r8a66597 *r8a66597, u16 pipenum) |
500 | { | 511 | { |
501 | r8a66597_mdfy(r8a66597, MBW | pipenum, MBW | CURPIPE, CFIFOSEL); | 512 | unsigned short mbw = mbw_value(r8a66597); |
513 | |||
514 | r8a66597_mdfy(r8a66597, mbw | pipenum, mbw | CURPIPE, CFIFOSEL); | ||
502 | r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, pipenum); | 515 | r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, pipenum); |
503 | } | 516 | } |
504 | 517 | ||
@@ -506,11 +519,13 @@ static inline void cfifo_change(struct r8a66597 *r8a66597, u16 pipenum) | |||
506 | static inline void fifo_change_from_pipe(struct r8a66597 *r8a66597, | 519 | static inline void fifo_change_from_pipe(struct r8a66597 *r8a66597, |
507 | struct r8a66597_pipe *pipe) | 520 | struct r8a66597_pipe *pipe) |
508 | { | 521 | { |
522 | unsigned short mbw = mbw_value(r8a66597); | ||
523 | |||
509 | cfifo_change(r8a66597, 0); | 524 | cfifo_change(r8a66597, 0); |
510 | r8a66597_mdfy(r8a66597, MBW | 0, MBW | CURPIPE, D0FIFOSEL); | 525 | r8a66597_mdfy(r8a66597, mbw | 0, mbw | CURPIPE, D0FIFOSEL); |
511 | r8a66597_mdfy(r8a66597, MBW | 0, MBW | CURPIPE, D1FIFOSEL); | 526 | r8a66597_mdfy(r8a66597, mbw | 0, mbw | CURPIPE, D1FIFOSEL); |
512 | 527 | ||
513 | r8a66597_mdfy(r8a66597, MBW | pipe->info.pipenum, MBW | CURPIPE, | 528 | r8a66597_mdfy(r8a66597, mbw | pipe->info.pipenum, mbw | CURPIPE, |
514 | pipe->fifosel); | 529 | pipe->fifosel); |
515 | r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, pipe->info.pipenum); | 530 | r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, pipe->info.pipenum); |
516 | } | 531 | } |
@@ -742,9 +757,13 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, | |||
742 | struct r8a66597_pipe *pipe, | 757 | struct r8a66597_pipe *pipe, |
743 | struct urb *urb) | 758 | struct urb *urb) |
744 | { | 759 | { |
745 | #if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
746 | int i; | 760 | int i; |
747 | struct r8a66597_pipe_info *info = &pipe->info; | 761 | struct r8a66597_pipe_info *info = &pipe->info; |
762 | unsigned short mbw = mbw_value(r8a66597); | ||
763 | |||
764 | /* pipe dma is only for external controlles */ | ||
765 | if (r8a66597->pdata->on_chip) | ||
766 | return; | ||
748 | 767 | ||
749 | if ((pipe->info.pipenum != 0) && (info->type != R8A66597_INT)) { | 768 | if ((pipe->info.pipenum != 0) && (info->type != R8A66597_INT)) { |
750 | for (i = 0; i < R8A66597_MAX_DMA_CHANNEL; i++) { | 769 | for (i = 0; i < R8A66597_MAX_DMA_CHANNEL; i++) { |
@@ -763,8 +782,8 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, | |||
763 | set_pipe_reg_addr(pipe, i); | 782 | set_pipe_reg_addr(pipe, i); |
764 | 783 | ||
765 | cfifo_change(r8a66597, 0); | 784 | cfifo_change(r8a66597, 0); |
766 | r8a66597_mdfy(r8a66597, MBW | pipe->info.pipenum, | 785 | r8a66597_mdfy(r8a66597, mbw | pipe->info.pipenum, |
767 | MBW | CURPIPE, pipe->fifosel); | 786 | mbw | CURPIPE, pipe->fifosel); |
768 | 787 | ||
769 | r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, | 788 | r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, |
770 | pipe->info.pipenum); | 789 | pipe->info.pipenum); |
@@ -772,7 +791,6 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, | |||
772 | break; | 791 | break; |
773 | } | 792 | } |
774 | } | 793 | } |
775 | #endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */ | ||
776 | } | 794 | } |
777 | 795 | ||
778 | /* this function must be called with interrupt disabled */ | 796 | /* this function must be called with interrupt disabled */ |
@@ -1769,7 +1787,7 @@ static void r8a66597_timer(unsigned long _r8a66597) | |||
1769 | 1787 | ||
1770 | spin_lock_irqsave(&r8a66597->lock, flags); | 1788 | spin_lock_irqsave(&r8a66597->lock, flags); |
1771 | 1789 | ||
1772 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) | 1790 | for (port = 0; port < r8a66597->max_root_hub; port++) |
1773 | r8a66597_root_hub_control(r8a66597, port); | 1791 | r8a66597_root_hub_control(r8a66597, port); |
1774 | 1792 | ||
1775 | spin_unlock_irqrestore(&r8a66597->lock, flags); | 1793 | spin_unlock_irqrestore(&r8a66597->lock, flags); |
@@ -1807,7 +1825,7 @@ static void set_address_zero(struct r8a66597 *r8a66597, struct urb *urb) | |||
1807 | u16 root_port, hub_port; | 1825 | u16 root_port, hub_port; |
1808 | 1826 | ||
1809 | if (usb_address == 0) { | 1827 | if (usb_address == 0) { |
1810 | get_port_number(urb->dev->devpath, | 1828 | get_port_number(r8a66597, urb->dev->devpath, |
1811 | &root_port, &hub_port); | 1829 | &root_port, &hub_port); |
1812 | set_devadd_reg(r8a66597, 0, | 1830 | set_devadd_reg(r8a66597, 0, |
1813 | get_r8a66597_usb_speed(urb->dev->speed), | 1831 | get_r8a66597_usb_speed(urb->dev->speed), |
@@ -2082,7 +2100,7 @@ static int r8a66597_hub_status_data(struct usb_hcd *hcd, char *buf) | |||
2082 | 2100 | ||
2083 | *buf = 0; /* initialize (no change) */ | 2101 | *buf = 0; /* initialize (no change) */ |
2084 | 2102 | ||
2085 | for (i = 0; i < R8A66597_MAX_ROOT_HUB; i++) { | 2103 | for (i = 0; i < r8a66597->max_root_hub; i++) { |
2086 | if (r8a66597->root_hub[i].port & 0xffff0000) | 2104 | if (r8a66597->root_hub[i].port & 0xffff0000) |
2087 | *buf |= 1 << (i + 1); | 2105 | *buf |= 1 << (i + 1); |
2088 | } | 2106 | } |
@@ -2097,11 +2115,11 @@ static void r8a66597_hub_descriptor(struct r8a66597 *r8a66597, | |||
2097 | { | 2115 | { |
2098 | desc->bDescriptorType = 0x29; | 2116 | desc->bDescriptorType = 0x29; |
2099 | desc->bHubContrCurrent = 0; | 2117 | desc->bHubContrCurrent = 0; |
2100 | desc->bNbrPorts = R8A66597_MAX_ROOT_HUB; | 2118 | desc->bNbrPorts = r8a66597->max_root_hub; |
2101 | desc->bDescLength = 9; | 2119 | desc->bDescLength = 9; |
2102 | desc->bPwrOn2PwrGood = 0; | 2120 | desc->bPwrOn2PwrGood = 0; |
2103 | desc->wHubCharacteristics = cpu_to_le16(0x0011); | 2121 | desc->wHubCharacteristics = cpu_to_le16(0x0011); |
2104 | desc->bitmap[0] = ((1 << R8A66597_MAX_ROOT_HUB) - 1) << 1; | 2122 | desc->bitmap[0] = ((1 << r8a66597->max_root_hub) - 1) << 1; |
2105 | desc->bitmap[1] = ~0; | 2123 | desc->bitmap[1] = ~0; |
2106 | } | 2124 | } |
2107 | 2125 | ||
@@ -2129,7 +2147,7 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
2129 | } | 2147 | } |
2130 | break; | 2148 | break; |
2131 | case ClearPortFeature: | 2149 | case ClearPortFeature: |
2132 | if (wIndex > R8A66597_MAX_ROOT_HUB) | 2150 | if (wIndex > r8a66597->max_root_hub) |
2133 | goto error; | 2151 | goto error; |
2134 | if (wLength != 0) | 2152 | if (wLength != 0) |
2135 | goto error; | 2153 | goto error; |
@@ -2162,12 +2180,12 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
2162 | *buf = 0x00; | 2180 | *buf = 0x00; |
2163 | break; | 2181 | break; |
2164 | case GetPortStatus: | 2182 | case GetPortStatus: |
2165 | if (wIndex > R8A66597_MAX_ROOT_HUB) | 2183 | if (wIndex > r8a66597->max_root_hub) |
2166 | goto error; | 2184 | goto error; |
2167 | *(__le32 *)buf = cpu_to_le32(rh->port); | 2185 | *(__le32 *)buf = cpu_to_le32(rh->port); |
2168 | break; | 2186 | break; |
2169 | case SetPortFeature: | 2187 | case SetPortFeature: |
2170 | if (wIndex > R8A66597_MAX_ROOT_HUB) | 2188 | if (wIndex > r8a66597->max_root_hub) |
2171 | goto error; | 2189 | goto error; |
2172 | if (wLength != 0) | 2190 | if (wLength != 0) |
2173 | goto error; | 2191 | goto error; |
@@ -2216,7 +2234,7 @@ static int r8a66597_bus_suspend(struct usb_hcd *hcd) | |||
2216 | 2234 | ||
2217 | dbg("%s", __func__); | 2235 | dbg("%s", __func__); |
2218 | 2236 | ||
2219 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { | 2237 | for (port = 0; port < r8a66597->max_root_hub; port++) { |
2220 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; | 2238 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; |
2221 | unsigned long dvstctr_reg = get_dvstctr_reg(port); | 2239 | unsigned long dvstctr_reg = get_dvstctr_reg(port); |
2222 | 2240 | ||
@@ -2247,7 +2265,7 @@ static int r8a66597_bus_resume(struct usb_hcd *hcd) | |||
2247 | 2265 | ||
2248 | dbg("%s", __func__); | 2266 | dbg("%s", __func__); |
2249 | 2267 | ||
2250 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { | 2268 | for (port = 0; port < r8a66597->max_root_hub; port++) { |
2251 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; | 2269 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; |
2252 | unsigned long dvstctr_reg = get_dvstctr_reg(port); | 2270 | unsigned long dvstctr_reg = get_dvstctr_reg(port); |
2253 | 2271 | ||
@@ -2314,7 +2332,7 @@ static int r8a66597_suspend(struct device *dev) | |||
2314 | 2332 | ||
2315 | disable_controller(r8a66597); | 2333 | disable_controller(r8a66597); |
2316 | 2334 | ||
2317 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { | 2335 | for (port = 0; port < r8a66597->max_root_hub; port++) { |
2318 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; | 2336 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; |
2319 | 2337 | ||
2320 | rh->port = 0x00000000; | 2338 | rh->port = 0x00000000; |
@@ -2354,8 +2372,9 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) | |||
2354 | del_timer_sync(&r8a66597->rh_timer); | 2372 | del_timer_sync(&r8a66597->rh_timer); |
2355 | usb_remove_hcd(hcd); | 2373 | usb_remove_hcd(hcd); |
2356 | iounmap((void *)r8a66597->reg); | 2374 | iounmap((void *)r8a66597->reg); |
2357 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 2375 | #ifdef CONFIG_HAVE_CLK |
2358 | clk_put(r8a66597->clk); | 2376 | if (r8a66597->pdata->on_chip) |
2377 | clk_put(r8a66597->clk); | ||
2359 | #endif | 2378 | #endif |
2360 | usb_put_hcd(hcd); | 2379 | usb_put_hcd(hcd); |
2361 | return 0; | 2380 | return 0; |
@@ -2363,7 +2382,7 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) | |||
2363 | 2382 | ||
2364 | static int __devinit r8a66597_probe(struct platform_device *pdev) | 2383 | static int __devinit r8a66597_probe(struct platform_device *pdev) |
2365 | { | 2384 | { |
2366 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 2385 | #ifdef CONFIG_HAVE_CLK |
2367 | char clk_name[8]; | 2386 | char clk_name[8]; |
2368 | #endif | 2387 | #endif |
2369 | struct resource *res = NULL, *ires; | 2388 | struct resource *res = NULL, *ires; |
@@ -2425,15 +2444,20 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
2425 | r8a66597->pdata = pdev->dev.platform_data; | 2444 | r8a66597->pdata = pdev->dev.platform_data; |
2426 | r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; | 2445 | r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; |
2427 | 2446 | ||
2428 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 2447 | if (r8a66597->pdata->on_chip) { |
2429 | snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); | 2448 | #ifdef CONFIG_HAVE_CLK |
2430 | r8a66597->clk = clk_get(&pdev->dev, clk_name); | 2449 | snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); |
2431 | if (IS_ERR(r8a66597->clk)) { | 2450 | r8a66597->clk = clk_get(&pdev->dev, clk_name); |
2432 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); | 2451 | if (IS_ERR(r8a66597->clk)) { |
2433 | ret = PTR_ERR(r8a66597->clk); | 2452 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", |
2434 | goto clean_up2; | 2453 | clk_name); |
2435 | } | 2454 | ret = PTR_ERR(r8a66597->clk); |
2455 | goto clean_up2; | ||
2456 | } | ||
2436 | #endif | 2457 | #endif |
2458 | r8a66597->max_root_hub = 1; | ||
2459 | } else | ||
2460 | r8a66597->max_root_hub = 2; | ||
2437 | 2461 | ||
2438 | spin_lock_init(&r8a66597->lock); | 2462 | spin_lock_init(&r8a66597->lock); |
2439 | init_timer(&r8a66597->rh_timer); | 2463 | init_timer(&r8a66597->rh_timer); |
@@ -2463,8 +2487,9 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
2463 | return 0; | 2487 | return 0; |
2464 | 2488 | ||
2465 | clean_up3: | 2489 | clean_up3: |
2466 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 2490 | #ifdef CONFIG_HAVE_CLK |
2467 | clk_put(r8a66597->clk); | 2491 | if (r8a66597->pdata->on_chip) |
2492 | clk_put(r8a66597->clk); | ||
2468 | clean_up2: | 2493 | clean_up2: |
2469 | #endif | 2494 | #endif |
2470 | usb_put_hcd(hcd); | 2495 | usb_put_hcd(hcd); |
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h index d72680b433f9..eecbd917bc81 100644 --- a/drivers/usb/host/r8a66597.h +++ b/drivers/usb/host/r8a66597.h | |||
@@ -26,7 +26,7 @@ | |||
26 | #ifndef __R8A66597_H__ | 26 | #ifndef __R8A66597_H__ |
27 | #define __R8A66597_H__ | 27 | #define __R8A66597_H__ |
28 | 28 | ||
29 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 29 | #ifdef CONFIG_HAVE_CLK |
30 | #include <linux/clk.h> | 30 | #include <linux/clk.h> |
31 | #endif | 31 | #endif |
32 | 32 | ||
@@ -193,13 +193,9 @@ | |||
193 | #define REW 0x4000 /* b14: Buffer rewind */ | 193 | #define REW 0x4000 /* b14: Buffer rewind */ |
194 | #define DCLRM 0x2000 /* b13: DMA buffer clear mode */ | 194 | #define DCLRM 0x2000 /* b13: DMA buffer clear mode */ |
195 | #define DREQE 0x1000 /* b12: DREQ output enable */ | 195 | #define DREQE 0x1000 /* b12: DREQ output enable */ |
196 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
197 | #define MBW 0x0800 | ||
198 | #else | ||
199 | #define MBW 0x0400 /* b10: Maximum bit width for FIFO access */ | ||
200 | #endif | ||
201 | #define MBW_8 0x0000 /* 8bit */ | 196 | #define MBW_8 0x0000 /* 8bit */ |
202 | #define MBW_16 0x0400 /* 16bit */ | 197 | #define MBW_16 0x0400 /* 16bit */ |
198 | #define MBW_32 0x0800 /* 32bit */ | ||
203 | #define BIGEND 0x0100 /* b8: Big endian mode */ | 199 | #define BIGEND 0x0100 /* b8: Big endian mode */ |
204 | #define BYTE_LITTLE 0x0000 /* little dendian */ | 200 | #define BYTE_LITTLE 0x0000 /* little dendian */ |
205 | #define BYTE_BIG 0x0100 /* big endifan */ | 201 | #define BYTE_BIG 0x0100 /* big endifan */ |
@@ -405,11 +401,7 @@ | |||
405 | #define R8A66597_MAX_NUM_PIPE 10 | 401 | #define R8A66597_MAX_NUM_PIPE 10 |
406 | #define R8A66597_BUF_BSIZE 8 | 402 | #define R8A66597_BUF_BSIZE 8 |
407 | #define R8A66597_MAX_DEVICE 10 | 403 | #define R8A66597_MAX_DEVICE 10 |
408 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
409 | #define R8A66597_MAX_ROOT_HUB 1 | ||
410 | #else | ||
411 | #define R8A66597_MAX_ROOT_HUB 2 | 404 | #define R8A66597_MAX_ROOT_HUB 2 |
412 | #endif | ||
413 | #define R8A66597_MAX_SAMPLING 5 | 405 | #define R8A66597_MAX_SAMPLING 5 |
414 | #define R8A66597_RH_POLL_TIME 10 | 406 | #define R8A66597_RH_POLL_TIME 10 |
415 | #define R8A66597_MAX_DMA_CHANNEL 2 | 407 | #define R8A66597_MAX_DMA_CHANNEL 2 |
@@ -487,7 +479,7 @@ struct r8a66597_root_hub { | |||
487 | struct r8a66597 { | 479 | struct r8a66597 { |
488 | spinlock_t lock; | 480 | spinlock_t lock; |
489 | unsigned long reg; | 481 | unsigned long reg; |
490 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 482 | #ifdef CONFIG_HAVE_CLK |
491 | struct clk *clk; | 483 | struct clk *clk; |
492 | #endif | 484 | #endif |
493 | struct r8a66597_platdata *pdata; | 485 | struct r8a66597_platdata *pdata; |
@@ -504,6 +496,7 @@ struct r8a66597 { | |||
504 | unsigned short interval_map; | 496 | unsigned short interval_map; |
505 | unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE]; | 497 | unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE]; |
506 | unsigned char dma_map; | 498 | unsigned char dma_map; |
499 | unsigned int max_root_hub; | ||
507 | 500 | ||
508 | struct list_head child_device; | 501 | struct list_head child_device; |
509 | unsigned long child_connect_map[4]; | 502 | unsigned long child_connect_map[4]; |
@@ -550,21 +543,22 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597, | |||
550 | unsigned long offset, u16 *buf, | 543 | unsigned long offset, u16 *buf, |
551 | int len) | 544 | int len) |
552 | { | 545 | { |
553 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
554 | unsigned long fifoaddr = r8a66597->reg + offset; | 546 | unsigned long fifoaddr = r8a66597->reg + offset; |
555 | unsigned long count; | 547 | unsigned long count; |
556 | 548 | ||
557 | count = len / 4; | 549 | if (r8a66597->pdata->on_chip) { |
558 | insl(fifoaddr, buf, count); | 550 | count = len / 4; |
551 | insl(fifoaddr, buf, count); | ||
559 | 552 | ||
560 | if (len & 0x00000003) { | 553 | if (len & 0x00000003) { |
561 | unsigned long tmp = inl(fifoaddr); | 554 | unsigned long tmp = inl(fifoaddr); |
562 | memcpy((unsigned char *)buf + count * 4, &tmp, len & 0x03); | 555 | memcpy((unsigned char *)buf + count * 4, &tmp, |
556 | len & 0x03); | ||
557 | } | ||
558 | } else { | ||
559 | len = (len + 1) / 2; | ||
560 | insw(fifoaddr, buf, len); | ||
563 | } | 561 | } |
564 | #else | ||
565 | len = (len + 1) / 2; | ||
566 | insw(r8a66597->reg + offset, buf, len); | ||
567 | #endif | ||
568 | } | 562 | } |
569 | 563 | ||
570 | static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val, | 564 | static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val, |
@@ -578,33 +572,33 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, | |||
578 | int len) | 572 | int len) |
579 | { | 573 | { |
580 | unsigned long fifoaddr = r8a66597->reg + offset; | 574 | unsigned long fifoaddr = r8a66597->reg + offset; |
581 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
582 | unsigned long count; | 575 | unsigned long count; |
583 | unsigned char *pb; | 576 | unsigned char *pb; |
584 | int i; | 577 | int i; |
585 | 578 | ||
586 | count = len / 4; | 579 | if (r8a66597->pdata->on_chip) { |
587 | outsl(fifoaddr, buf, count); | 580 | count = len / 4; |
581 | outsl(fifoaddr, buf, count); | ||
582 | |||
583 | if (len & 0x00000003) { | ||
584 | pb = (unsigned char *)buf + count * 4; | ||
585 | for (i = 0; i < (len & 0x00000003); i++) { | ||
586 | if (r8a66597_read(r8a66597, CFIFOSEL) & BIGEND) | ||
587 | outb(pb[i], fifoaddr + i); | ||
588 | else | ||
589 | outb(pb[i], fifoaddr + 3 - i); | ||
590 | } | ||
591 | } | ||
592 | } else { | ||
593 | int odd = len & 0x0001; | ||
588 | 594 | ||
589 | if (len & 0x00000003) { | 595 | len = len / 2; |
590 | pb = (unsigned char *)buf + count * 4; | 596 | outsw(fifoaddr, buf, len); |
591 | for (i = 0; i < (len & 0x00000003); i++) { | 597 | if (unlikely(odd)) { |
592 | if (r8a66597_read(r8a66597, CFIFOSEL) & BIGEND) | 598 | buf = &buf[len]; |
593 | outb(pb[i], fifoaddr + i); | 599 | outb((unsigned char)*buf, fifoaddr); |
594 | else | ||
595 | outb(pb[i], fifoaddr + 3 - i); | ||
596 | } | 600 | } |
597 | } | 601 | } |
598 | #else | ||
599 | int odd = len & 0x0001; | ||
600 | |||
601 | len = len / 2; | ||
602 | outsw(fifoaddr, buf, len); | ||
603 | if (unlikely(odd)) { | ||
604 | buf = &buf[len]; | ||
605 | outb((unsigned char)*buf, fifoaddr); | ||
606 | } | ||
607 | #endif | ||
608 | } | 602 | } |
609 | 603 | ||
610 | static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, | 604 | static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, |