aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAdrian McMenamin <adrian@newgolddream.dyndns.info>2008-02-24 09:30:23 -0500
committerPaul Mundt <lethal@linux-sh.org>2008-02-26 00:12:09 -0500
commitbd49666974a12f39eb9c74044e0b1753efcd94c4 (patch)
tree84637532bd0ae58904abec0940797186885993d5 /drivers
parentb7fd095602468ee501c5bcc3f9ca788cb3834096 (diff)
maple: fix device detection
The maple bus driver that went into the kernel mainline in September 2007 contained some bugs which were revealed by the update of the kobj code for the current release series. Unfortunately those bugs also helped ensure maple devices were properly detected. This patch (against the current git) now ensures that devices are properly detected again. (A previous attempt to fix this by delaying initialisation only partially fixed this - as became apparent when the bus was fully loaded) Signed-off-by: Adrian McMenamin <adrian@mcmen.demon.co.uk> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/sh/maple/maple.c66
1 files changed, 43 insertions, 23 deletions
diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index 9cfcfd8dad5e..617efb1640b1 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Core maple bus functionality 2 * Core maple bus functionality
3 * 3 *
4 * Copyright (C) 2007 Adrian McMenamin 4 * Copyright (C) 2007, 2008 Adrian McMenamin
5 * 5 *
6 * Based on 2.4 code by: 6 * Based on 2.4 code by:
7 * 7 *
@@ -18,7 +18,6 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/module.h>
22#include <linux/interrupt.h> 21#include <linux/interrupt.h>
23#include <linux/list.h> 22#include <linux/list.h>
24#include <linux/io.h> 23#include <linux/io.h>
@@ -54,7 +53,7 @@ static struct device maple_bus;
54static int subdevice_map[MAPLE_PORTS]; 53static int subdevice_map[MAPLE_PORTS];
55static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr; 54static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
56static unsigned long maple_pnp_time; 55static unsigned long maple_pnp_time;
57static int started, scanning, liststatus, realscan; 56static int started, scanning, liststatus, fullscan;
58static struct kmem_cache *maple_queue_cache; 57static struct kmem_cache *maple_queue_cache;
59 58
60struct maple_device_specify { 59struct maple_device_specify {
@@ -62,6 +61,9 @@ struct maple_device_specify {
62 int unit; 61 int unit;
63}; 62};
64 63
64static bool checked[4];
65static struct maple_device *baseunits[4];
66
65/** 67/**
66 * maple_driver_register - register a device driver 68 * maple_driver_register - register a device driver
67 * automatically makes the driver bus a maple bus 69 * automatically makes the driver bus a maple bus
@@ -309,11 +311,9 @@ static void maple_attach_driver(struct maple_device *mdev)
309 else 311 else
310 break; 312 break;
311 313
312 if (realscan) { 314 printk(KERN_INFO "Maple device detected: %s\n",
313 printk(KERN_INFO "Maple device detected: %s\n", 315 mdev->product_name);
314 mdev->product_name); 316 printk(KERN_INFO "Maple device: %s\n", mdev->product_licence);
315 printk(KERN_INFO "Maple device: %s\n", mdev->product_licence);
316 }
317 317
318 function = be32_to_cpu(mdev->devinfo.function); 318 function = be32_to_cpu(mdev->devinfo.function);
319 319
@@ -323,10 +323,9 @@ static void maple_attach_driver(struct maple_device *mdev)
323 mdev->driver = &maple_dummy_driver; 323 mdev->driver = &maple_dummy_driver;
324 sprintf(mdev->dev.bus_id, "%d:0.port", mdev->port); 324 sprintf(mdev->dev.bus_id, "%d:0.port", mdev->port);
325 } else { 325 } else {
326 if (realscan) 326 printk(KERN_INFO
327 printk(KERN_INFO 327 "Maple bus at (%d, %d): Function 0x%lX\n",
328 "Maple bus at (%d, %d): Function 0x%lX\n", 328 mdev->port, mdev->unit, function);
329 mdev->port, mdev->unit, function);
330 329
331 matched = 330 matched =
332 bus_for_each_drv(&maple_bus_type, NULL, mdev, 331 bus_for_each_drv(&maple_bus_type, NULL, mdev,
@@ -334,9 +333,8 @@ static void maple_attach_driver(struct maple_device *mdev)
334 333
335 if (matched == 0) { 334 if (matched == 0) {
336 /* Driver does not exist yet */ 335 /* Driver does not exist yet */
337 if (realscan) 336 printk(KERN_INFO
338 printk(KERN_INFO 337 "No maple driver found.\n");
339 "No maple driver found.\n");
340 mdev->driver = &maple_dummy_driver; 338 mdev->driver = &maple_dummy_driver;
341 } 339 }
342 sprintf(mdev->dev.bus_id, "%d:0%d.%lX", mdev->port, 340 sprintf(mdev->dev.bus_id, "%d:0%d.%lX", mdev->port,
@@ -472,9 +470,12 @@ static void maple_response_none(struct maple_device *mdev,
472 maple_detach_driver(mdev); 470 maple_detach_driver(mdev);
473 return; 471 return;
474 } 472 }
475 if (!started) { 473 if (!started || !fullscan) {
476 printk(KERN_INFO "No maple devices attached to port %d\n", 474 if (checked[mdev->port] == false) {
477 mdev->port); 475 checked[mdev->port] = true;
476 printk(KERN_INFO "No maple devices attached"
477 " to port %d\n", mdev->port);
478 }
478 return; 479 return;
479 } 480 }
480 maple_clean_submap(mdev); 481 maple_clean_submap(mdev);
@@ -485,8 +486,14 @@ static void maple_response_devinfo(struct maple_device *mdev,
485 char *recvbuf) 486 char *recvbuf)
486{ 487{
487 char submask; 488 char submask;
488 if ((!started) || (scanning == 2)) { 489 if (!started || (scanning == 2) || !fullscan) {
489 maple_attach_driver(mdev); 490 if ((mdev->unit == 0) && (checked[mdev->port] == false)) {
491 checked[mdev->port] = true;
492 maple_attach_driver(mdev);
493 } else {
494 if (mdev->unit != 0)
495 maple_attach_driver(mdev);
496 }
490 return; 497 return;
491 } 498 }
492 if (mdev->unit == 0) { 499 if (mdev->unit == 0) {
@@ -505,6 +512,7 @@ static void maple_dma_handler(struct work_struct *work)
505 struct maple_device *dev; 512 struct maple_device *dev;
506 char *recvbuf; 513 char *recvbuf;
507 enum maple_code code; 514 enum maple_code code;
515 int i;
508 516
509 if (!maple_dma_done()) 517 if (!maple_dma_done())
510 return; 518 return;
@@ -557,6 +565,19 @@ static void maple_dma_handler(struct work_struct *work)
557 } else 565 } else
558 scanning = 0; 566 scanning = 0;
559 567
568 if (!fullscan) {
569 fullscan = 1;
570 for (i = 0; i < MAPLE_PORTS; i++) {
571 if (checked[i] == false) {
572 fullscan = 0;
573 dev = baseunits[i];
574 dev->mq->command =
575 MAPLE_COMMAND_DEVINFO;
576 dev->mq->length = 0;
577 maple_add_packet(dev->mq);
578 }
579 }
580 }
560 if (started == 0) 581 if (started == 0)
561 started = 1; 582 started = 1;
562 } 583 }
@@ -694,7 +715,9 @@ static int __init maple_bus_init(void)
694 715
695 /* setup maple ports */ 716 /* setup maple ports */
696 for (i = 0; i < MAPLE_PORTS; i++) { 717 for (i = 0; i < MAPLE_PORTS; i++) {
718 checked[i] = false;
697 mdev[i] = maple_alloc_dev(i, 0); 719 mdev[i] = maple_alloc_dev(i, 0);
720 baseunits[i] = mdev[i];
698 if (!mdev[i]) { 721 if (!mdev[i]) {
699 while (i-- > 0) 722 while (i-- > 0)
700 maple_free_dev(mdev[i]); 723 maple_free_dev(mdev[i]);
@@ -703,12 +726,9 @@ static int __init maple_bus_init(void)
703 mdev[i]->mq->command = MAPLE_COMMAND_DEVINFO; 726 mdev[i]->mq->command = MAPLE_COMMAND_DEVINFO;
704 mdev[i]->mq->length = 0; 727 mdev[i]->mq->length = 0;
705 maple_add_packet(mdev[i]->mq); 728 maple_add_packet(mdev[i]->mq);
706 /* delay aids hardware detection */
707 mdelay(5);
708 subdevice_map[i] = 0; 729 subdevice_map[i] = 0;
709 } 730 }
710 731
711 realscan = 1;
712 /* setup maplebus hardware */ 732 /* setup maplebus hardware */
713 maplebus_dma_reset(); 733 maplebus_dma_reset();
714 /* initial detection */ 734 /* initial detection */