diff options
Diffstat (limited to 'drivers/usb/host/r8a66597-hcd.c')
-rw-r--r-- | drivers/usb/host/r8a66597-hcd.c | 209 |
1 files changed, 119 insertions, 90 deletions
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index 56976cc0352a..82dce3e0d4d7 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/sched.h> | 28 | #include <linux/sched.h> |
29 | #include <linux/smp_lock.h> | ||
30 | #include <linux/errno.h> | 29 | #include <linux/errno.h> |
31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
32 | #include <linux/timer.h> | 31 | #include <linux/timer.h> |
@@ -92,43 +91,43 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) | |||
92 | u16 tmp; | 91 | u16 tmp; |
93 | int i = 0; | 92 | int i = 0; |
94 | 93 | ||
95 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | 94 | if (r8a66597->pdata->on_chip) { |
96 | #if defined(CONFIG_HAVE_CLK) | 95 | #ifdef CONFIG_HAVE_CLK |
97 | clk_enable(r8a66597->clk); | 96 | clk_enable(r8a66597->clk); |
98 | #endif | 97 | #endif |
99 | do { | 98 | do { |
100 | r8a66597_write(r8a66597, SCKE, SYSCFG0); | 99 | r8a66597_write(r8a66597, SCKE, SYSCFG0); |
101 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 100 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
102 | if (i++ > 1000) { | 101 | if (i++ > 1000) { |
103 | printk(KERN_ERR "r8a66597: register access fail.\n"); | 102 | printk(KERN_ERR "r8a66597: reg access fail.\n"); |
104 | return -ENXIO; | 103 | return -ENXIO; |
105 | } | 104 | } |
106 | } while ((tmp & SCKE) != SCKE); | 105 | } while ((tmp & SCKE) != SCKE); |
107 | r8a66597_write(r8a66597, 0x04, 0x02); | 106 | r8a66597_write(r8a66597, 0x04, 0x02); |
108 | #else | 107 | } else { |
109 | do { | 108 | do { |
110 | r8a66597_write(r8a66597, USBE, SYSCFG0); | 109 | r8a66597_write(r8a66597, USBE, SYSCFG0); |
111 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 110 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
112 | if (i++ > 1000) { | 111 | if (i++ > 1000) { |
113 | printk(KERN_ERR "r8a66597: register access fail.\n"); | 112 | printk(KERN_ERR "r8a66597: reg access fail.\n"); |
114 | return -ENXIO; | 113 | return -ENXIO; |
115 | } | 114 | } |
116 | } while ((tmp & USBE) != USBE); | 115 | } while ((tmp & USBE) != USBE); |
117 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); | 116 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); |
118 | r8a66597_mdfy(r8a66597, get_xtal_from_pdata(r8a66597->pdata), XTAL, | 117 | r8a66597_mdfy(r8a66597, get_xtal_from_pdata(r8a66597->pdata), |
119 | SYSCFG0); | 118 | XTAL, SYSCFG0); |
120 | 119 | ||
121 | i = 0; | 120 | i = 0; |
122 | r8a66597_bset(r8a66597, XCKE, SYSCFG0); | 121 | r8a66597_bset(r8a66597, XCKE, SYSCFG0); |
123 | do { | 122 | do { |
124 | msleep(1); | 123 | msleep(1); |
125 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 124 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
126 | if (i++ > 500) { | 125 | if (i++ > 500) { |
127 | printk(KERN_ERR "r8a66597: register access fail.\n"); | 126 | printk(KERN_ERR "r8a66597: reg access fail.\n"); |
128 | return -ENXIO; | 127 | return -ENXIO; |
129 | } | 128 | } |
130 | } while ((tmp & SCKE) != SCKE); | 129 | } while ((tmp & SCKE) != SCKE); |
131 | #endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */ | 130 | } |
132 | 131 | ||
133 | return 0; | 132 | return 0; |
134 | } | 133 | } |
@@ -137,15 +136,16 @@ static void r8a66597_clock_disable(struct r8a66597 *r8a66597) | |||
137 | { | 136 | { |
138 | r8a66597_bclr(r8a66597, SCKE, SYSCFG0); | 137 | r8a66597_bclr(r8a66597, SCKE, SYSCFG0); |
139 | udelay(1); | 138 | udelay(1); |
140 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | 139 | |
141 | #if defined(CONFIG_HAVE_CLK) | 140 | if (r8a66597->pdata->on_chip) { |
142 | clk_disable(r8a66597->clk); | 141 | #ifdef CONFIG_HAVE_CLK |
143 | #endif | 142 | clk_disable(r8a66597->clk); |
144 | #else | ||
145 | r8a66597_bclr(r8a66597, PLLC, SYSCFG0); | ||
146 | r8a66597_bclr(r8a66597, XCKE, SYSCFG0); | ||
147 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); | ||
148 | #endif | 143 | #endif |
144 | } else { | ||
145 | r8a66597_bclr(r8a66597, PLLC, SYSCFG0); | ||
146 | r8a66597_bclr(r8a66597, XCKE, SYSCFG0); | ||
147 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); | ||
148 | } | ||
149 | } | 149 | } |
150 | 150 | ||
151 | static void r8a66597_enable_port(struct r8a66597 *r8a66597, int port) | 151 | static void r8a66597_enable_port(struct r8a66597 *r8a66597, int port) |
@@ -206,7 +206,7 @@ static int enable_controller(struct r8a66597 *r8a66597) | |||
206 | 206 | ||
207 | r8a66597_bset(r8a66597, SIGNE | SACKE, INTENB1); | 207 | r8a66597_bset(r8a66597, SIGNE | SACKE, INTENB1); |
208 | 208 | ||
209 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) | 209 | for (port = 0; port < r8a66597->max_root_hub; port++) |
210 | r8a66597_enable_port(r8a66597, port); | 210 | r8a66597_enable_port(r8a66597, port); |
211 | 211 | ||
212 | return 0; | 212 | return 0; |
@@ -219,7 +219,7 @@ static void disable_controller(struct r8a66597 *r8a66597) | |||
219 | r8a66597_write(r8a66597, 0, INTENB0); | 219 | r8a66597_write(r8a66597, 0, INTENB0); |
220 | r8a66597_write(r8a66597, 0, INTSTS0); | 220 | r8a66597_write(r8a66597, 0, INTSTS0); |
221 | 221 | ||
222 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) | 222 | for (port = 0; port < r8a66597->max_root_hub; port++) |
223 | r8a66597_disable_port(r8a66597, port); | 223 | r8a66597_disable_port(r8a66597, port); |
224 | 224 | ||
225 | r8a66597_clock_disable(r8a66597); | 225 | r8a66597_clock_disable(r8a66597); |
@@ -250,11 +250,12 @@ static int is_hub_limit(char *devpath) | |||
250 | return ((strlen(devpath) >= 4) ? 1 : 0); | 250 | return ((strlen(devpath) >= 4) ? 1 : 0); |
251 | } | 251 | } |
252 | 252 | ||
253 | 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) | ||
254 | { | 255 | { |
255 | if (root_port) { | 256 | if (root_port) { |
256 | *root_port = (devpath[0] & 0x0F) - 1; | 257 | *root_port = (devpath[0] & 0x0F) - 1; |
257 | if (*root_port >= R8A66597_MAX_ROOT_HUB) | 258 | if (*root_port >= r8a66597->max_root_hub) |
258 | printk(KERN_ERR "r8a66597: Illegal root port number.\n"); | 259 | printk(KERN_ERR "r8a66597: Illegal root port number.\n"); |
259 | } | 260 | } |
260 | if (hub_port) | 261 | if (hub_port) |
@@ -356,7 +357,8 @@ static int make_r8a66597_device(struct r8a66597 *r8a66597, | |||
356 | INIT_LIST_HEAD(&dev->device_list); | 357 | INIT_LIST_HEAD(&dev->device_list); |
357 | list_add_tail(&dev->device_list, &r8a66597->child_device); | 358 | list_add_tail(&dev->device_list, &r8a66597->child_device); |
358 | 359 | ||
359 | 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); | ||
360 | if (!is_child_device(urb->dev->devpath)) | 362 | if (!is_child_device(urb->dev->devpath)) |
361 | r8a66597->root_hub[dev->root_port].dev = dev; | 363 | r8a66597->root_hub[dev->root_port].dev = dev; |
362 | 364 | ||
@@ -421,7 +423,7 @@ static void free_usb_address(struct r8a66597 *r8a66597, | |||
421 | list_del(&dev->device_list); | 423 | list_del(&dev->device_list); |
422 | kfree(dev); | 424 | kfree(dev); |
423 | 425 | ||
424 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { | 426 | for (port = 0; port < r8a66597->max_root_hub; port++) { |
425 | if (r8a66597->root_hub[port].dev == dev) { | 427 | if (r8a66597->root_hub[port].dev == dev) { |
426 | r8a66597->root_hub[port].dev = NULL; | 428 | r8a66597->root_hub[port].dev = NULL; |
427 | break; | 429 | break; |
@@ -496,10 +498,20 @@ static void r8a66597_pipe_toggle(struct r8a66597 *r8a66597, | |||
496 | r8a66597_bset(r8a66597, SQCLR, pipe->pipectr); | 498 | r8a66597_bset(r8a66597, SQCLR, pipe->pipectr); |
497 | } | 499 | } |
498 | 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 | |||
499 | /* this function must be called with interrupt disabled */ | 509 | /* this function must be called with interrupt disabled */ |
500 | static inline void cfifo_change(struct r8a66597 *r8a66597, u16 pipenum) | 510 | static inline void cfifo_change(struct r8a66597 *r8a66597, u16 pipenum) |
501 | { | 511 | { |
502 | 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); | ||
503 | r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, pipenum); | 515 | r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, pipenum); |
504 | } | 516 | } |
505 | 517 | ||
@@ -507,11 +519,13 @@ static inline void cfifo_change(struct r8a66597 *r8a66597, u16 pipenum) | |||
507 | static inline void fifo_change_from_pipe(struct r8a66597 *r8a66597, | 519 | static inline void fifo_change_from_pipe(struct r8a66597 *r8a66597, |
508 | struct r8a66597_pipe *pipe) | 520 | struct r8a66597_pipe *pipe) |
509 | { | 521 | { |
522 | unsigned short mbw = mbw_value(r8a66597); | ||
523 | |||
510 | cfifo_change(r8a66597, 0); | 524 | cfifo_change(r8a66597, 0); |
511 | r8a66597_mdfy(r8a66597, MBW | 0, MBW | CURPIPE, D0FIFOSEL); | 525 | r8a66597_mdfy(r8a66597, mbw | 0, mbw | CURPIPE, D0FIFOSEL); |
512 | r8a66597_mdfy(r8a66597, MBW | 0, MBW | CURPIPE, D1FIFOSEL); | 526 | r8a66597_mdfy(r8a66597, mbw | 0, mbw | CURPIPE, D1FIFOSEL); |
513 | 527 | ||
514 | r8a66597_mdfy(r8a66597, MBW | pipe->info.pipenum, MBW | CURPIPE, | 528 | r8a66597_mdfy(r8a66597, mbw | pipe->info.pipenum, mbw | CURPIPE, |
515 | pipe->fifosel); | 529 | pipe->fifosel); |
516 | r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, pipe->info.pipenum); | 530 | r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, pipe->info.pipenum); |
517 | } | 531 | } |
@@ -743,9 +757,13 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, | |||
743 | struct r8a66597_pipe *pipe, | 757 | struct r8a66597_pipe *pipe, |
744 | struct urb *urb) | 758 | struct urb *urb) |
745 | { | 759 | { |
746 | #if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
747 | int i; | 760 | int i; |
748 | 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; | ||
749 | 767 | ||
750 | if ((pipe->info.pipenum != 0) && (info->type != R8A66597_INT)) { | 768 | if ((pipe->info.pipenum != 0) && (info->type != R8A66597_INT)) { |
751 | for (i = 0; i < R8A66597_MAX_DMA_CHANNEL; i++) { | 769 | for (i = 0; i < R8A66597_MAX_DMA_CHANNEL; i++) { |
@@ -764,8 +782,8 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, | |||
764 | set_pipe_reg_addr(pipe, i); | 782 | set_pipe_reg_addr(pipe, i); |
765 | 783 | ||
766 | cfifo_change(r8a66597, 0); | 784 | cfifo_change(r8a66597, 0); |
767 | r8a66597_mdfy(r8a66597, MBW | pipe->info.pipenum, | 785 | r8a66597_mdfy(r8a66597, mbw | pipe->info.pipenum, |
768 | MBW | CURPIPE, pipe->fifosel); | 786 | mbw | CURPIPE, pipe->fifosel); |
769 | 787 | ||
770 | r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, | 788 | r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, |
771 | pipe->info.pipenum); | 789 | pipe->info.pipenum); |
@@ -773,7 +791,6 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, | |||
773 | break; | 791 | break; |
774 | } | 792 | } |
775 | } | 793 | } |
776 | #endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */ | ||
777 | } | 794 | } |
778 | 795 | ||
779 | /* this function must be called with interrupt disabled */ | 796 | /* this function must be called with interrupt disabled */ |
@@ -1770,7 +1787,7 @@ static void r8a66597_timer(unsigned long _r8a66597) | |||
1770 | 1787 | ||
1771 | spin_lock_irqsave(&r8a66597->lock, flags); | 1788 | spin_lock_irqsave(&r8a66597->lock, flags); |
1772 | 1789 | ||
1773 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) | 1790 | for (port = 0; port < r8a66597->max_root_hub; port++) |
1774 | r8a66597_root_hub_control(r8a66597, port); | 1791 | r8a66597_root_hub_control(r8a66597, port); |
1775 | 1792 | ||
1776 | spin_unlock_irqrestore(&r8a66597->lock, flags); | 1793 | spin_unlock_irqrestore(&r8a66597->lock, flags); |
@@ -1808,7 +1825,7 @@ static void set_address_zero(struct r8a66597 *r8a66597, struct urb *urb) | |||
1808 | u16 root_port, hub_port; | 1825 | u16 root_port, hub_port; |
1809 | 1826 | ||
1810 | if (usb_address == 0) { | 1827 | if (usb_address == 0) { |
1811 | get_port_number(urb->dev->devpath, | 1828 | get_port_number(r8a66597, urb->dev->devpath, |
1812 | &root_port, &hub_port); | 1829 | &root_port, &hub_port); |
1813 | set_devadd_reg(r8a66597, 0, | 1830 | set_devadd_reg(r8a66597, 0, |
1814 | get_r8a66597_usb_speed(urb->dev->speed), | 1831 | get_r8a66597_usb_speed(urb->dev->speed), |
@@ -2083,7 +2100,7 @@ static int r8a66597_hub_status_data(struct usb_hcd *hcd, char *buf) | |||
2083 | 2100 | ||
2084 | *buf = 0; /* initialize (no change) */ | 2101 | *buf = 0; /* initialize (no change) */ |
2085 | 2102 | ||
2086 | for (i = 0; i < R8A66597_MAX_ROOT_HUB; i++) { | 2103 | for (i = 0; i < r8a66597->max_root_hub; i++) { |
2087 | if (r8a66597->root_hub[i].port & 0xffff0000) | 2104 | if (r8a66597->root_hub[i].port & 0xffff0000) |
2088 | *buf |= 1 << (i + 1); | 2105 | *buf |= 1 << (i + 1); |
2089 | } | 2106 | } |
@@ -2098,11 +2115,11 @@ static void r8a66597_hub_descriptor(struct r8a66597 *r8a66597, | |||
2098 | { | 2115 | { |
2099 | desc->bDescriptorType = 0x29; | 2116 | desc->bDescriptorType = 0x29; |
2100 | desc->bHubContrCurrent = 0; | 2117 | desc->bHubContrCurrent = 0; |
2101 | desc->bNbrPorts = R8A66597_MAX_ROOT_HUB; | 2118 | desc->bNbrPorts = r8a66597->max_root_hub; |
2102 | desc->bDescLength = 9; | 2119 | desc->bDescLength = 9; |
2103 | desc->bPwrOn2PwrGood = 0; | 2120 | desc->bPwrOn2PwrGood = 0; |
2104 | desc->wHubCharacteristics = cpu_to_le16(0x0011); | 2121 | desc->wHubCharacteristics = cpu_to_le16(0x0011); |
2105 | desc->bitmap[0] = ((1 << R8A66597_MAX_ROOT_HUB) - 1) << 1; | 2122 | desc->bitmap[0] = ((1 << r8a66597->max_root_hub) - 1) << 1; |
2106 | desc->bitmap[1] = ~0; | 2123 | desc->bitmap[1] = ~0; |
2107 | } | 2124 | } |
2108 | 2125 | ||
@@ -2130,7 +2147,7 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
2130 | } | 2147 | } |
2131 | break; | 2148 | break; |
2132 | case ClearPortFeature: | 2149 | case ClearPortFeature: |
2133 | if (wIndex > R8A66597_MAX_ROOT_HUB) | 2150 | if (wIndex > r8a66597->max_root_hub) |
2134 | goto error; | 2151 | goto error; |
2135 | if (wLength != 0) | 2152 | if (wLength != 0) |
2136 | goto error; | 2153 | goto error; |
@@ -2163,12 +2180,12 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
2163 | *buf = 0x00; | 2180 | *buf = 0x00; |
2164 | break; | 2181 | break; |
2165 | case GetPortStatus: | 2182 | case GetPortStatus: |
2166 | if (wIndex > R8A66597_MAX_ROOT_HUB) | 2183 | if (wIndex > r8a66597->max_root_hub) |
2167 | goto error; | 2184 | goto error; |
2168 | *(__le32 *)buf = cpu_to_le32(rh->port); | 2185 | *(__le32 *)buf = cpu_to_le32(rh->port); |
2169 | break; | 2186 | break; |
2170 | case SetPortFeature: | 2187 | case SetPortFeature: |
2171 | if (wIndex > R8A66597_MAX_ROOT_HUB) | 2188 | if (wIndex > r8a66597->max_root_hub) |
2172 | goto error; | 2189 | goto error; |
2173 | if (wLength != 0) | 2190 | if (wLength != 0) |
2174 | goto error; | 2191 | goto error; |
@@ -2217,7 +2234,7 @@ static int r8a66597_bus_suspend(struct usb_hcd *hcd) | |||
2217 | 2234 | ||
2218 | dbg("%s", __func__); | 2235 | dbg("%s", __func__); |
2219 | 2236 | ||
2220 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { | 2237 | for (port = 0; port < r8a66597->max_root_hub; port++) { |
2221 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; | 2238 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; |
2222 | unsigned long dvstctr_reg = get_dvstctr_reg(port); | 2239 | unsigned long dvstctr_reg = get_dvstctr_reg(port); |
2223 | 2240 | ||
@@ -2248,7 +2265,7 @@ static int r8a66597_bus_resume(struct usb_hcd *hcd) | |||
2248 | 2265 | ||
2249 | dbg("%s", __func__); | 2266 | dbg("%s", __func__); |
2250 | 2267 | ||
2251 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { | 2268 | for (port = 0; port < r8a66597->max_root_hub; port++) { |
2252 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; | 2269 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; |
2253 | unsigned long dvstctr_reg = get_dvstctr_reg(port); | 2270 | unsigned long dvstctr_reg = get_dvstctr_reg(port); |
2254 | 2271 | ||
@@ -2306,16 +2323,16 @@ static struct hc_driver r8a66597_hc_driver = { | |||
2306 | }; | 2323 | }; |
2307 | 2324 | ||
2308 | #if defined(CONFIG_PM) | 2325 | #if defined(CONFIG_PM) |
2309 | static int r8a66597_suspend(struct platform_device *pdev, pm_message_t state) | 2326 | static int r8a66597_suspend(struct device *dev) |
2310 | { | 2327 | { |
2311 | struct r8a66597 *r8a66597 = dev_get_drvdata(&pdev->dev); | 2328 | struct r8a66597 *r8a66597 = dev_get_drvdata(dev); |
2312 | int port; | 2329 | int port; |
2313 | 2330 | ||
2314 | dbg("%s", __func__); | 2331 | dbg("%s", __func__); |
2315 | 2332 | ||
2316 | disable_controller(r8a66597); | 2333 | disable_controller(r8a66597); |
2317 | 2334 | ||
2318 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { | 2335 | for (port = 0; port < r8a66597->max_root_hub; port++) { |
2319 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; | 2336 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; |
2320 | 2337 | ||
2321 | rh->port = 0x00000000; | 2338 | rh->port = 0x00000000; |
@@ -2324,9 +2341,9 @@ static int r8a66597_suspend(struct platform_device *pdev, pm_message_t state) | |||
2324 | return 0; | 2341 | return 0; |
2325 | } | 2342 | } |
2326 | 2343 | ||
2327 | static int r8a66597_resume(struct platform_device *pdev) | 2344 | static int r8a66597_resume(struct device *dev) |
2328 | { | 2345 | { |
2329 | struct r8a66597 *r8a66597 = dev_get_drvdata(&pdev->dev); | 2346 | struct r8a66597 *r8a66597 = dev_get_drvdata(dev); |
2330 | struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597); | 2347 | struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597); |
2331 | 2348 | ||
2332 | dbg("%s", __func__); | 2349 | dbg("%s", __func__); |
@@ -2336,9 +2353,15 @@ static int r8a66597_resume(struct platform_device *pdev) | |||
2336 | 2353 | ||
2337 | return 0; | 2354 | return 0; |
2338 | } | 2355 | } |
2356 | |||
2357 | static struct dev_pm_ops r8a66597_dev_pm_ops = { | ||
2358 | .suspend = r8a66597_suspend, | ||
2359 | .resume = r8a66597_resume, | ||
2360 | }; | ||
2361 | |||
2362 | #define R8A66597_DEV_PM_OPS (&r8a66597_dev_pm_ops) | ||
2339 | #else /* if defined(CONFIG_PM) */ | 2363 | #else /* if defined(CONFIG_PM) */ |
2340 | #define r8a66597_suspend NULL | 2364 | #define R8A66597_DEV_PM_OPS NULL |
2341 | #define r8a66597_resume NULL | ||
2342 | #endif | 2365 | #endif |
2343 | 2366 | ||
2344 | static int __init_or_module r8a66597_remove(struct platform_device *pdev) | 2367 | static int __init_or_module r8a66597_remove(struct platform_device *pdev) |
@@ -2349,8 +2372,9 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) | |||
2349 | del_timer_sync(&r8a66597->rh_timer); | 2372 | del_timer_sync(&r8a66597->rh_timer); |
2350 | usb_remove_hcd(hcd); | 2373 | usb_remove_hcd(hcd); |
2351 | iounmap((void *)r8a66597->reg); | 2374 | iounmap((void *)r8a66597->reg); |
2352 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 2375 | #ifdef CONFIG_HAVE_CLK |
2353 | clk_put(r8a66597->clk); | 2376 | if (r8a66597->pdata->on_chip) |
2377 | clk_put(r8a66597->clk); | ||
2354 | #endif | 2378 | #endif |
2355 | usb_put_hcd(hcd); | 2379 | usb_put_hcd(hcd); |
2356 | return 0; | 2380 | return 0; |
@@ -2358,7 +2382,7 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) | |||
2358 | 2382 | ||
2359 | static int __devinit r8a66597_probe(struct platform_device *pdev) | 2383 | static int __devinit r8a66597_probe(struct platform_device *pdev) |
2360 | { | 2384 | { |
2361 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 2385 | #ifdef CONFIG_HAVE_CLK |
2362 | char clk_name[8]; | 2386 | char clk_name[8]; |
2363 | #endif | 2387 | #endif |
2364 | struct resource *res = NULL, *ires; | 2388 | struct resource *res = NULL, *ires; |
@@ -2420,15 +2444,20 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
2420 | r8a66597->pdata = pdev->dev.platform_data; | 2444 | r8a66597->pdata = pdev->dev.platform_data; |
2421 | r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; | 2445 | r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; |
2422 | 2446 | ||
2423 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 2447 | if (r8a66597->pdata->on_chip) { |
2424 | snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); | 2448 | #ifdef CONFIG_HAVE_CLK |
2425 | r8a66597->clk = clk_get(&pdev->dev, clk_name); | 2449 | snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); |
2426 | if (IS_ERR(r8a66597->clk)) { | 2450 | r8a66597->clk = clk_get(&pdev->dev, clk_name); |
2427 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); | 2451 | if (IS_ERR(r8a66597->clk)) { |
2428 | ret = PTR_ERR(r8a66597->clk); | 2452 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", |
2429 | goto clean_up2; | 2453 | clk_name); |
2430 | } | 2454 | ret = PTR_ERR(r8a66597->clk); |
2455 | goto clean_up2; | ||
2456 | } | ||
2431 | #endif | 2457 | #endif |
2458 | r8a66597->max_root_hub = 1; | ||
2459 | } else | ||
2460 | r8a66597->max_root_hub = 2; | ||
2432 | 2461 | ||
2433 | spin_lock_init(&r8a66597->lock); | 2462 | spin_lock_init(&r8a66597->lock); |
2434 | init_timer(&r8a66597->rh_timer); | 2463 | init_timer(&r8a66597->rh_timer); |
@@ -2458,8 +2487,9 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
2458 | return 0; | 2487 | return 0; |
2459 | 2488 | ||
2460 | clean_up3: | 2489 | clean_up3: |
2461 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 2490 | #ifdef CONFIG_HAVE_CLK |
2462 | clk_put(r8a66597->clk); | 2491 | if (r8a66597->pdata->on_chip) |
2492 | clk_put(r8a66597->clk); | ||
2463 | clean_up2: | 2493 | clean_up2: |
2464 | #endif | 2494 | #endif |
2465 | usb_put_hcd(hcd); | 2495 | usb_put_hcd(hcd); |
@@ -2474,11 +2504,10 @@ clean_up: | |||
2474 | static struct platform_driver r8a66597_driver = { | 2504 | static struct platform_driver r8a66597_driver = { |
2475 | .probe = r8a66597_probe, | 2505 | .probe = r8a66597_probe, |
2476 | .remove = r8a66597_remove, | 2506 | .remove = r8a66597_remove, |
2477 | .suspend = r8a66597_suspend, | ||
2478 | .resume = r8a66597_resume, | ||
2479 | .driver = { | 2507 | .driver = { |
2480 | .name = (char *) hcd_name, | 2508 | .name = (char *) hcd_name, |
2481 | .owner = THIS_MODULE, | 2509 | .owner = THIS_MODULE, |
2510 | .pm = R8A66597_DEV_PM_OPS, | ||
2482 | }, | 2511 | }, |
2483 | }; | 2512 | }; |
2484 | 2513 | ||