aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/r8a66597-hcd.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-10-17 18:43:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-17 18:43:52 -0400
commit0cfd81031a26717fe14380d18275f8e217571615 (patch)
tree78a84e4cb97e7f45eb77dc0fbd8857a5dd717869 /drivers/usb/host/r8a66597-hcd.c
parentf7ea4a4ba84f382e8eb143e435551de0feee5b4b (diff)
parent802f389a2cc6e2771b8de915ac241456d41eb79e (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (94 commits) USB: remove err() macro from more usb drivers USB: remove err() macro from usb misc drivers USB: remove err() macro from usb core code USB: remove err() macro from usb class drivers USB: remove use of err() in drivers/usb/serial USB: remove info() macro from usb mtd drivers USB: remove info() macro from usb input drivers USB: remove info() macro from usb network drivers USB: remove info() macro from remaining usb drivers USB: remove info() macro from usb/misc drivers USB: remove info() macro from usb/serial drivers USB: remove warn macro from HID core USB: remove warn() macro from usb drivers USB: remove warn() macro from usb net drivers USB: remove warn() macro from usb media drivers USB: remove warn() macro from usb input drivers usb/fsl_qe_udc: clear data toggle on clear halt request usb/fsl_qe_udc: fix response to get status request fsl_usb2_udc: Fix oops on probe failure. fsl_usb2_udc: Add a wmb before priming endpoint. ...
Diffstat (limited to 'drivers/usb/host/r8a66597-hcd.c')
-rw-r--r--drivers/usb/host/r8a66597-hcd.c101
1 files changed, 65 insertions, 36 deletions
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index ea7126f99cab..c18d8790c410 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -66,7 +66,7 @@ static unsigned short endian;
66module_param(endian, ushort, 0644); 66module_param(endian, ushort, 0644);
67MODULE_PARM_DESC(endian, "data endian: big=256, little=0 (default=0)"); 67MODULE_PARM_DESC(endian, "data endian: big=256, little=0 (default=0)");
68 68
69static unsigned short irq_sense = INTL; 69static unsigned short irq_sense = 0xff;
70module_param(irq_sense, ushort, 0644); 70module_param(irq_sense, ushort, 0644);
71MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=32, falling edge=0 " 71MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=32, falling edge=0 "
72 "(default=32)"); 72 "(default=32)");
@@ -118,7 +118,7 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597)
118 r8a66597_write(r8a66597, SCKE, SYSCFG0); 118 r8a66597_write(r8a66597, SCKE, SYSCFG0);
119 tmp = r8a66597_read(r8a66597, SYSCFG0); 119 tmp = r8a66597_read(r8a66597, SYSCFG0);
120 if (i++ > 1000) { 120 if (i++ > 1000) {
121 err("register access fail."); 121 printk(KERN_ERR "r8a66597: register access fail.\n");
122 return -ENXIO; 122 return -ENXIO;
123 } 123 }
124 } while ((tmp & SCKE) != SCKE); 124 } while ((tmp & SCKE) != SCKE);
@@ -128,7 +128,7 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597)
128 r8a66597_write(r8a66597, USBE, SYSCFG0); 128 r8a66597_write(r8a66597, USBE, SYSCFG0);
129 tmp = r8a66597_read(r8a66597, SYSCFG0); 129 tmp = r8a66597_read(r8a66597, SYSCFG0);
130 if (i++ > 1000) { 130 if (i++ > 1000) {
131 err("register access fail."); 131 printk(KERN_ERR "r8a66597: register access fail.\n");
132 return -ENXIO; 132 return -ENXIO;
133 } 133 }
134 } while ((tmp & USBE) != USBE); 134 } while ((tmp & USBE) != USBE);
@@ -141,7 +141,7 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597)
141 msleep(1); 141 msleep(1);
142 tmp = r8a66597_read(r8a66597, SYSCFG0); 142 tmp = r8a66597_read(r8a66597, SYSCFG0);
143 if (i++ > 500) { 143 if (i++ > 500) {
144 err("register access fail."); 144 printk(KERN_ERR "r8a66597: register access fail.\n");
145 return -ENXIO; 145 return -ENXIO;
146 } 146 }
147 } while ((tmp & SCKE) != SCKE); 147 } while ((tmp & SCKE) != SCKE);
@@ -265,7 +265,7 @@ static void get_port_number(char *devpath, u16 *root_port, u16 *hub_port)
265 if (root_port) { 265 if (root_port) {
266 *root_port = (devpath[0] & 0x0F) - 1; 266 *root_port = (devpath[0] & 0x0F) - 1;
267 if (*root_port >= R8A66597_MAX_ROOT_HUB) 267 if (*root_port >= R8A66597_MAX_ROOT_HUB)
268 err("illegal root port number"); 268 printk(KERN_ERR "r8a66597: Illegal root port number.\n");
269 } 269 }
270 if (hub_port) 270 if (hub_port)
271 *hub_port = devpath[2] & 0x0F; 271 *hub_port = devpath[2] & 0x0F;
@@ -286,7 +286,7 @@ static u16 get_r8a66597_usb_speed(enum usb_device_speed speed)
286 usbspd = HSMODE; 286 usbspd = HSMODE;
287 break; 287 break;
288 default: 288 default:
289 err("unknown speed"); 289 printk(KERN_ERR "r8a66597: unknown speed\n");
290 break; 290 break;
291 } 291 }
292 292
@@ -385,7 +385,7 @@ static u8 alloc_usb_address(struct r8a66597 *r8a66597, struct urb *urb)
385 struct r8a66597_device *dev; 385 struct r8a66597_device *dev;
386 386
387 if (is_hub_limit(urb->dev->devpath)) { 387 if (is_hub_limit(urb->dev->devpath)) {
388 err("Externel hub limit reached."); 388 dev_err(&urb->dev->dev, "External hub limit reached.\n");
389 return 0; 389 return 0;
390 } 390 }
391 391
@@ -406,8 +406,9 @@ static u8 alloc_usb_address(struct r8a66597 *r8a66597, struct urb *urb)
406 return addr; 406 return addr;
407 } 407 }
408 408
409 err("cannot communicate with a USB device more than 10.(%x)", 409 dev_err(&urb->dev->dev,
410 r8a66597->address_map); 410 "cannot communicate with a USB device more than 10.(%x)\n",
411 r8a66597->address_map);
411 412
412 return 0; 413 return 0;
413} 414}
@@ -447,7 +448,8 @@ static void r8a66597_reg_wait(struct r8a66597 *r8a66597, unsigned long reg,
447 do { 448 do {
448 tmp = r8a66597_read(r8a66597, reg); 449 tmp = r8a66597_read(r8a66597, reg);
449 if (i++ > 1000000) { 450 if (i++ > 1000000) {
450 err("register%lx, loop %x is timeout", reg, loop); 451 printk(KERN_ERR "r8a66597: register%lx, loop %x "
452 "is timeout\n", reg, loop);
451 break; 453 break;
452 } 454 }
453 ndelay(1); 455 ndelay(1);
@@ -675,7 +677,7 @@ static u16 get_empty_pipenum(struct r8a66597 *r8a66597,
675 array[i++] = 1; 677 array[i++] = 1;
676 break; 678 break;
677 default: 679 default:
678 err("Illegal type"); 680 printk(KERN_ERR "r8a66597: Illegal type\n");
679 return 0; 681 return 0;
680 } 682 }
681 683
@@ -705,7 +707,7 @@ static u16 get_r8a66597_type(__u8 type)
705 r8a66597_type = R8A66597_ISO; 707 r8a66597_type = R8A66597_ISO;
706 break; 708 break;
707 default: 709 default:
708 err("Illegal type"); 710 printk(KERN_ERR "r8a66597: Illegal type\n");
709 r8a66597_type = 0x0000; 711 r8a66597_type = 0x0000;
710 break; 712 break;
711 } 713 }
@@ -724,7 +726,7 @@ static u16 get_bufnum(u16 pipenum)
724 else if (check_interrupt(pipenum)) 726 else if (check_interrupt(pipenum))
725 bufnum = 4 + (pipenum - 6); 727 bufnum = 4 + (pipenum - 6);
726 else 728 else
727 err("Illegal pipenum (%d)", pipenum); 729 printk(KERN_ERR "r8a66597: Illegal pipenum (%d)\n", pipenum);
728 730
729 return bufnum; 731 return bufnum;
730} 732}
@@ -740,7 +742,7 @@ static u16 get_buf_bsize(u16 pipenum)
740 else if (check_interrupt(pipenum)) 742 else if (check_interrupt(pipenum))
741 buf_bsize = 0; 743 buf_bsize = 0;
742 else 744 else
743 err("Illegal pipenum (%d)", pipenum); 745 printk(KERN_ERR "r8a66597: Illegal pipenum (%d)\n", pipenum);
744 746
745 return buf_bsize; 747 return buf_bsize;
746} 748}
@@ -760,10 +762,12 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597,
760 if ((r8a66597->dma_map & (1 << i)) != 0) 762 if ((r8a66597->dma_map & (1 << i)) != 0)
761 continue; 763 continue;
762 764
763 info("address %d, EndpointAddress 0x%02x use DMA FIFO", 765 dev_info(&dev->udev->dev,
764 usb_pipedevice(urb->pipe), 766 "address %d, EndpointAddress 0x%02x use "
765 info->dir_in ? USB_ENDPOINT_DIR_MASK + info->epnum 767 "DMA FIFO\n", usb_pipedevice(urb->pipe),
766 : info->epnum); 768 info->dir_in ?
769 USB_ENDPOINT_DIR_MASK + info->epnum
770 : info->epnum);
767 771
768 r8a66597->dma_map |= 1 << i; 772 r8a66597->dma_map |= 1 << i;
769 dev->dma_map |= 1 << i; 773 dev->dma_map |= 1 << i;
@@ -1187,7 +1191,7 @@ static int start_transfer(struct r8a66597 *r8a66597, struct r8a66597_td *td)
1187 prepare_status_packet(r8a66597, td); 1191 prepare_status_packet(r8a66597, td);
1188 break; 1192 break;
1189 default: 1193 default:
1190 err("invalid type."); 1194 printk(KERN_ERR "r8a66597: invalid type.\n");
1191 break; 1195 break;
1192 } 1196 }
1193 1197
@@ -1295,7 +1299,7 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum)
1295 if (unlikely((tmp & FRDY) == 0)) { 1299 if (unlikely((tmp & FRDY) == 0)) {
1296 pipe_stop(r8a66597, td->pipe); 1300 pipe_stop(r8a66597, td->pipe);
1297 pipe_irq_disable(r8a66597, pipenum); 1301 pipe_irq_disable(r8a66597, pipenum);
1298 err("in fifo not ready (%d)", pipenum); 1302 printk(KERN_ERR "r8a66597: in fifo not ready (%d)\n", pipenum);
1299 finish_request(r8a66597, td, pipenum, td->urb, -EPIPE); 1303 finish_request(r8a66597, td, pipenum, td->urb, -EPIPE);
1300 return; 1304 return;
1301 } 1305 }
@@ -1370,7 +1374,7 @@ static void packet_write(struct r8a66597 *r8a66597, u16 pipenum)
1370 if (unlikely((tmp & FRDY) == 0)) { 1374 if (unlikely((tmp & FRDY) == 0)) {
1371 pipe_stop(r8a66597, td->pipe); 1375 pipe_stop(r8a66597, td->pipe);
1372 pipe_irq_disable(r8a66597, pipenum); 1376 pipe_irq_disable(r8a66597, pipenum);
1373 err("out write fifo not ready. (%d)", pipenum); 1377 printk(KERN_ERR "r8a66597: out fifo not ready (%d)\n", pipenum);
1374 finish_request(r8a66597, td, pipenum, urb, -EPIPE); 1378 finish_request(r8a66597, td, pipenum, urb, -EPIPE);
1375 return; 1379 return;
1376 } 1380 }
@@ -2005,7 +2009,7 @@ static struct r8a66597_device *get_r8a66597_device(struct r8a66597 *r8a66597,
2005 return dev; 2009 return dev;
2006 } 2010 }
2007 2011
2008 err("get_r8a66597_device fail.(%d)\n", addr); 2012 printk(KERN_ERR "r8a66597: get_r8a66597_device fail.(%d)\n", addr);
2009 return NULL; 2013 return NULL;
2010} 2014}
2011 2015
@@ -2263,7 +2267,7 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev)
2263#define resource_len(r) (((r)->end - (r)->start) + 1) 2267#define resource_len(r) (((r)->end - (r)->start) + 1)
2264static int __init r8a66597_probe(struct platform_device *pdev) 2268static int __init r8a66597_probe(struct platform_device *pdev)
2265{ 2269{
2266 struct resource *res = NULL; 2270 struct resource *res = NULL, *ires;
2267 int irq = -1; 2271 int irq = -1;
2268 void __iomem *reg = NULL; 2272 void __iomem *reg = NULL;
2269 struct usb_hcd *hcd = NULL; 2273 struct usb_hcd *hcd = NULL;
@@ -2274,7 +2278,7 @@ static int __init r8a66597_probe(struct platform_device *pdev)
2274 2278
2275 if (pdev->dev.dma_mask) { 2279 if (pdev->dev.dma_mask) {
2276 ret = -EINVAL; 2280 ret = -EINVAL;
2277 err("dma not support"); 2281 dev_err(&pdev->dev, "dma not supported\n");
2278 goto clean_up; 2282 goto clean_up;
2279 } 2283 }
2280 2284
@@ -2282,21 +2286,25 @@ static int __init r8a66597_probe(struct platform_device *pdev)
2282 (char *)hcd_name); 2286 (char *)hcd_name);
2283 if (!res) { 2287 if (!res) {
2284 ret = -ENODEV; 2288 ret = -ENODEV;
2285 err("platform_get_resource_byname error."); 2289 dev_err(&pdev->dev, "platform_get_resource_byname error.\n");
2286 goto clean_up; 2290 goto clean_up;
2287 } 2291 }
2288 2292
2289 irq = platform_get_irq(pdev, 0); 2293 ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
2290 if (irq < 0) { 2294 if (!ires) {
2291 ret = -ENODEV; 2295 ret = -ENODEV;
2292 err("platform_get_irq error."); 2296 dev_err(&pdev->dev,
2297 "platform_get_resource IORESOURCE_IRQ error.\n");
2293 goto clean_up; 2298 goto clean_up;
2294 } 2299 }
2295 2300
2301 irq = ires->start;
2302 irq_trigger = ires->flags & IRQF_TRIGGER_MASK;
2303
2296 reg = ioremap(res->start, resource_len(res)); 2304 reg = ioremap(res->start, resource_len(res));
2297 if (reg == NULL) { 2305 if (reg == NULL) {
2298 ret = -ENOMEM; 2306 ret = -ENOMEM;
2299 err("ioremap error."); 2307 dev_err(&pdev->dev, "ioremap error.\n");
2300 goto clean_up; 2308 goto clean_up;
2301 } 2309 }
2302 2310
@@ -2304,7 +2312,7 @@ static int __init r8a66597_probe(struct platform_device *pdev)
2304 hcd = usb_create_hcd(&r8a66597_hc_driver, &pdev->dev, (char *)hcd_name); 2312 hcd = usb_create_hcd(&r8a66597_hc_driver, &pdev->dev, (char *)hcd_name);
2305 if (!hcd) { 2313 if (!hcd) {
2306 ret = -ENOMEM; 2314 ret = -ENOMEM;
2307 err("Failed to create hcd"); 2315 dev_err(&pdev->dev, "Failed to create hcd\n");
2308 goto clean_up; 2316 goto clean_up;
2309 } 2317 }
2310 r8a66597 = hcd_to_r8a66597(hcd); 2318 r8a66597 = hcd_to_r8a66597(hcd);
@@ -2329,13 +2337,33 @@ static int __init r8a66597_probe(struct platform_device *pdev)
2329 INIT_LIST_HEAD(&r8a66597->child_device); 2337 INIT_LIST_HEAD(&r8a66597->child_device);
2330 2338
2331 hcd->rsrc_start = res->start; 2339 hcd->rsrc_start = res->start;
2332 if (irq_sense == INTL) 2340
2333 irq_trigger = IRQF_TRIGGER_LOW; 2341 /* irq_sense setting on cmdline takes precedence over resource
2334 else 2342 * settings, so the introduction of irqflags in IRQ resourse
2335 irq_trigger = IRQF_TRIGGER_FALLING; 2343 * won't disturb existing setups */
2344 switch (irq_sense) {
2345 case INTL:
2346 irq_trigger = IRQF_TRIGGER_LOW;
2347 break;
2348 case 0:
2349 irq_trigger = IRQF_TRIGGER_FALLING;
2350 break;
2351 case 0xff:
2352 if (irq_trigger)
2353 irq_sense = (irq_trigger & IRQF_TRIGGER_LOW) ?
2354 INTL : 0;
2355 else {
2356 irq_sense = INTL;
2357 irq_trigger = IRQF_TRIGGER_LOW;
2358 }
2359 break;
2360 default:
2361 dev_err(&pdev->dev, "Unknown irq_sense value.\n");
2362 }
2363
2336 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); 2364 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger);
2337 if (ret != 0) { 2365 if (ret != 0) {
2338 err("Failed to add hcd"); 2366 dev_err(&pdev->dev, "Failed to add hcd\n");
2339 goto clean_up; 2367 goto clean_up;
2340 } 2368 }
2341 2369
@@ -2364,7 +2392,8 @@ static int __init r8a66597_init(void)
2364 if (usb_disabled()) 2392 if (usb_disabled())
2365 return -ENODEV; 2393 return -ENODEV;
2366 2394
2367 info("driver %s, %s", hcd_name, DRIVER_VERSION); 2395 printk(KERN_INFO KBUILD_MODNAME ": driver %s, %s\n", hcd_name,
2396 DRIVER_VERSION);
2368 return platform_driver_register(&r8a66597_driver); 2397 return platform_driver_register(&r8a66597_driver);
2369} 2398}
2370module_init(r8a66597_init); 2399module_init(r8a66597_init);