maple.c 16.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
/*
 * Core maple bus functionality
 *
 *  Copyright (C) 2007 Adrian McMenamin
 *
 * Based on 2.4 code by:
 *
 *  Copyright (C) 2000-2001 YAEGASHI Takeshi
 *  Copyright (C) 2001 M. R. Brown
 *  Copyright (C) 2001 Paul Mundt
 *
 * and others.
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 */
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/maple.h>
#include <linux/dma-mapping.h>
#include <asm/cacheflush.h>
#include <asm/dma.h>
#include <asm/io.h>
#include <asm/mach/dma.h>
#include <asm/mach/sysasic.h>
#include <asm/mach/maple.h>

MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, M.R. Brown, Adrian McMenamin");
MODULE_DESCRIPTION("Maple bus driver for Dreamcast");
MODULE_LICENSE("GPL v2");
MODULE_SUPPORTED_DEVICE("{{SEGA, Dreamcast/Maple}}");

static void maple_dma_handler(struct work_struct *work);
static void maple_vblank_handler(struct work_struct *work);

static DECLARE_WORK(maple_dma_process, maple_dma_handler);
static DECLARE_WORK(maple_vblank_process, maple_vblank_handler);

static LIST_HEAD(maple_waitq);
static LIST_HEAD(maple_sentq);

static DEFINE_MUTEX(maple_list_lock);

static struct maple_driver maple_dummy_driver;
static struct device maple_bus;
static int subdevice_map[MAPLE_PORTS];
static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
static unsigned long maple_pnp_time;
static int started, scanning, liststatus;
static struct kmem_cache *maple_queue_cache;

struct maple_device_specify {
60 61
	int port;
	int unit;
62 63 64 65 66 67 68 69 70
};

/**
 *  maple_driver_register - register a device driver
 *  automatically makes the driver bus a maple bus
 *  @drv: the driver to be registered
 */
int maple_driver_register(struct device_driver *drv)
{
71 72 73 74
	if (!drv)
		return -EINVAL;
	drv->bus = &maple_bus_type;
	return driver_register(drv);
75
}
76

77 78 79 80 81
EXPORT_SYMBOL_GPL(maple_driver_register);

/* set hardware registers to enable next round of dma */
static void maplebus_dma_reset(void)
{
82 83 84 85 86 87
	ctrl_outl(MAPLE_MAGIC, MAPLE_RESET);
	/* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */
	ctrl_outl(1, MAPLE_TRIGTYPE);
	ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(50000), MAPLE_SPEED);
	ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR);
	ctrl_outl(1, MAPLE_ENABLE);
88 89 90 91 92 93 94 95 96 97
}

/**
 * maple_getcond_callback - setup handling MAPLE_COMMAND_GETCOND
 * @dev: device responding
 * @callback: handler callback
 * @interval: interval in jiffies between callbacks
 * @function: the function code for the device
 */
void maple_getcond_callback(struct maple_device *dev,
98 99
			    void (*callback) (struct mapleq * mq),
			    unsigned long interval, unsigned long function)
100
{
101 102 103 104
	dev->callback = callback;
	dev->interval = interval;
	dev->function = cpu_to_be32(function);
	dev->when = jiffies;
105
}
106

107 108 109 110
EXPORT_SYMBOL_GPL(maple_getcond_callback);

static int maple_dma_done(void)
{
111
	return (ctrl_inl(MAPLE_STATE) & 1) == 0;
112 113 114 115
}

static void maple_release_device(struct device *dev)
{
116 117 118 119
	if (dev->type) {
		kfree(dev->type->name);
		kfree(dev->type);
	}
120 121 122 123 124 125 126 127
}

/**
 * maple_add_packet - add a single instruction to the queue
 * @mq: instruction to add to waiting queue
 */
void maple_add_packet(struct mapleq *mq)
{
128 129 130
	mutex_lock(&maple_list_lock);
	list_add(&mq->list, &maple_waitq);
	mutex_unlock(&maple_list_lock);
131
}
132

133 134 135 136
EXPORT_SYMBOL_GPL(maple_add_packet);

static struct mapleq *maple_allocq(struct maple_device *dev)
{
137
	struct mapleq *mq;
138

139 140 141
	mq = kmalloc(sizeof(*mq), GFP_KERNEL);
	if (!mq)
		return NULL;
142

143 144 145 146 147 148 149
	mq->dev = dev;
	mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
	mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp);
	if (!mq->recvbuf) {
		kfree(mq);
		return NULL;
	}
150

151
	return mq;
152 153 154 155
}

static struct maple_device *maple_alloc_dev(int port, int unit)
{
156
	struct maple_device *dev;
157

158 159 160
	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
	if (!dev)
		return NULL;
161

162 163 164
	dev->port = port;
	dev->unit = unit;
	dev->mq = maple_allocq(dev);
165

166 167 168 169
	if (!dev->mq) {
		kfree(dev);
		return NULL;
	}
170

171
	return dev;
172 173 174 175
}

static void maple_free_dev(struct maple_device *mdev)
{
176 177 178 179 180 181 182
	if (!mdev)
		return;
	if (mdev->mq) {
		kmem_cache_free(maple_queue_cache, mdev->mq->recvbufdcsp);
		kfree(mdev->mq);
	}
	kfree(mdev);
183 184 185 186 187 188 189
}

/* process the command queue into a maple command block
 * terminating command has bit 32 of first long set to 0
 */
static void maple_build_block(struct mapleq *mq)
{
190 191
	int port, unit, from, to, len;
	unsigned long *lsendbuf = mq->sendbuf;
192

193 194 195 196 197
	port = mq->dev->port & 3;
	unit = mq->dev->unit;
	len = mq->length;
	from = port << 6;
	to = (port << 6) | (unit > 0 ? (1 << (unit - 1)) & 0x1f : 0x20);
198

199 200
	*maple_lastptr &= 0x7fffffff;
	maple_lastptr = maple_sendptr;
201

202 203 204 205
	*maple_sendptr++ = (port << 16) | len | 0x80000000;
	*maple_sendptr++ = PHYSADDR(mq->recvbuf);
	*maple_sendptr++ =
	    mq->command | (to << 8) | (from << 16) | (len << 24);
206

207 208
	while (len-- > 0)
		*maple_sendptr++ = *lsendbuf++;
209 210 211 212 213
}

/* build up command queue */
static void maple_send(void)
{
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
	int i;
	int maple_packets;
	struct mapleq *mq, *nmq;

	if (!list_empty(&maple_sentq))
		return;
	if (list_empty(&maple_waitq) || !maple_dma_done())
		return;
	maple_packets = 0;
	maple_sendptr = maple_lastptr = maple_sendbuf;
	list_for_each_entry_safe(mq, nmq, &maple_waitq, list) {
		maple_build_block(mq);
		list_move(&mq->list, &maple_sentq);
		if (maple_packets++ > MAPLE_MAXPACKETS)
			break;
	}
	if (maple_packets > 0) {
		for (i = 0; i < (1 << MAPLE_DMA_PAGES); i++)
			dma_cache_sync(0, maple_sendbuf + i * PAGE_SIZE,
				       PAGE_SIZE, DMA_BIDIRECTIONAL);
	}
235 236 237
}

static int attach_matching_maple_driver(struct device_driver *driver,
238
					void *devptr)
239
{
240 241 242 243 244 245 246 247 248 249 250 251
	struct maple_driver *maple_drv;
	struct maple_device *mdev;

	mdev = devptr;
	maple_drv = to_maple_driver(driver);
	if (mdev->devinfo.function & be32_to_cpu(maple_drv->function)) {
		if (maple_drv->connect(mdev) == 0) {
			mdev->driver = maple_drv;
			return 1;
		}
	}
	return 0;
252 253 254 255
}

static void maple_detach_driver(struct maple_device *mdev)
{
256 257 258 259 260 261 262 263 264 265 266 267 268
	if (!mdev)
		return;
	if (mdev->driver) {
		if (mdev->driver->disconnect)
			mdev->driver->disconnect(mdev);
	}
	mdev->driver = NULL;
	if (mdev->registered) {
		maple_release_device(&mdev->dev);
		device_unregister(&mdev->dev);
	}
	mdev->registered = 0;
	maple_free_dev(mdev);
269 270 271 272 273
}

/* process initial MAPLE_COMMAND_DEVINFO for each device or port */
static void maple_attach_driver(struct maple_device *dev)
{
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
	char *p;

	char *recvbuf;
	unsigned long function;
	int matched, retval;

	recvbuf = dev->mq->recvbuf;
	memcpy(&dev->devinfo, recvbuf + 4, sizeof(dev->devinfo));
	memcpy(dev->product_name, dev->devinfo.product_name, 30);
	memcpy(dev->product_licence, dev->devinfo.product_licence, 60);
	dev->product_name[30] = '\0';
	dev->product_licence[60] = '\0';

	for (p = dev->product_name + 29; dev->product_name <= p; p--)
		if (*p == ' ')
			*p = '\0';
		else
			break;

	for (p = dev->product_licence + 59; dev->product_licence <= p; p--)
		if (*p == ' ')
			*p = '\0';
		else
			break;

	function = be32_to_cpu(dev->devinfo.function);

	if (function > 0x200) {
		/* Do this silently - as not a real device */
		function = 0;
		dev->driver = &maple_dummy_driver;
		sprintf(dev->dev.bus_id, "%d:0.port", dev->port);
	} else {
		printk(KERN_INFO
		       "Maple bus at (%d, %d): Connected function 0x%lX\n",
		       dev->port, dev->unit, function);

		matched =
		    bus_for_each_drv(&maple_bus_type, NULL, dev,
				     attach_matching_maple_driver);

		if (matched == 0) {
			/* Driver does not exist yet */
			printk(KERN_INFO
			       "No maple driver found for this device\n");
			dev->driver = &maple_dummy_driver;
		}

		sprintf(dev->dev.bus_id, "%d:0%d.%lX", dev->port,
			dev->unit, function);
	}
	dev->function = function;
	dev->dev.bus = &maple_bus_type;
	dev->dev.parent = &maple_bus;
	dev->dev.release = &maple_release_device;
	retval = device_register(&dev->dev);
	if (retval) {
		printk(KERN_INFO
		       "Maple bus: Attempt to register device (%x, %x) failed.\n",
		       dev->port, dev->unit);
		maple_free_dev(dev);
	}
	dev->registered = 1;
337 338 339 340 341 342 343 344 345
}

/*
 * if device has been registered for the given
 * port and unit then return 1 - allows identification
 * of which devices need to be attached or detached
 */
static int detach_maple_device(struct device *device, void *portptr)
{
346 347 348 349 350 351 352 353
	struct maple_device_specify *ds;
	struct maple_device *mdev;

	ds = portptr;
	mdev = to_maple_dev(device);
	if (mdev->port == ds->port && mdev->unit == ds->unit)
		return 1;
	return 0;
354 355 356 357
}

static int setup_maple_commands(struct device *device, void *ignored)
{
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
	struct maple_device *maple_dev = to_maple_dev(device);

	if ((maple_dev->interval > 0)
	    && time_after(jiffies, maple_dev->when)) {
		maple_dev->when = jiffies + maple_dev->interval;
		maple_dev->mq->command = MAPLE_COMMAND_GETCOND;
		maple_dev->mq->sendbuf = &maple_dev->function;
		maple_dev->mq->length = 1;
		maple_add_packet(maple_dev->mq);
		liststatus++;
	} else {
		if (time_after(jiffies, maple_pnp_time)) {
			maple_dev->mq->command = MAPLE_COMMAND_DEVINFO;
			maple_dev->mq->length = 0;
			maple_add_packet(maple_dev->mq);
			liststatus++;
		}
	}

	return 0;
378 379 380 381 382
}

/* VBLANK bottom half - implemented via workqueue */
static void maple_vblank_handler(struct work_struct *work)
{
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
	if (!maple_dma_done())
		return;
	if (!list_empty(&maple_sentq))
		return;
	ctrl_outl(0, MAPLE_ENABLE);
	liststatus = 0;
	bus_for_each_dev(&maple_bus_type, NULL, NULL,
			 setup_maple_commands);
	if (time_after(jiffies, maple_pnp_time))
		maple_pnp_time = jiffies + MAPLE_PNP_INTERVAL;
	if (liststatus && list_empty(&maple_sentq)) {
		INIT_LIST_HEAD(&maple_sentq);
		maple_send();
	}
	maplebus_dma_reset();
398 399 400 401 402
}

/* handle devices added via hotplugs - placing them on queue for DEVINFO*/
static void maple_map_subunits(struct maple_device *mdev, int submask)
{
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
	int retval, k, devcheck;
	struct maple_device *mdev_add;
	struct maple_device_specify ds;

	for (k = 0; k < 5; k++) {
		ds.port = mdev->port;
		ds.unit = k + 1;
		retval =
		    bus_for_each_dev(&maple_bus_type, NULL, &ds,
				     detach_maple_device);
		if (retval) {
			submask = submask >> 1;
			continue;
		}
		devcheck = submask & 0x01;
		if (devcheck) {
			mdev_add = maple_alloc_dev(mdev->port, k + 1);
			if (!mdev_add)
				return;
			mdev_add->mq->command = MAPLE_COMMAND_DEVINFO;
			mdev_add->mq->length = 0;
			maple_add_packet(mdev_add->mq);
			scanning = 1;
		}
		submask = submask >> 1;
	}
429 430 431 432 433
}

/* mark a device as removed */
static void maple_clean_submap(struct maple_device *mdev)
{
434
	int killbit;
435

436 437 438 439
	killbit = (mdev->unit > 0 ? (1 << (mdev->unit - 1)) & 0x1f : 0x20);
	killbit = ~killbit;
	killbit &= 0xFF;
	subdevice_map[mdev->port] = subdevice_map[mdev->port] & killbit;
440 441 442 443
}

/* handle empty port or hotplug removal */
static void maple_response_none(struct maple_device *mdev,
444
				struct mapleq *mq)
445
{
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
	if (mdev->unit != 0) {
		list_del(&mq->list);
		maple_clean_submap(mdev);
		printk(KERN_INFO
		       "Maple bus device detaching at (%d, %d)\n",
		       mdev->port, mdev->unit);
		maple_detach_driver(mdev);
		return;
	}
	if (!started) {
		printk(KERN_INFO "No maple devices attached to port %d\n",
		       mdev->port);
		return;
	}
	maple_clean_submap(mdev);
461 462 463 464
}

/* preprocess hotplugs or scans */
static void maple_response_devinfo(struct maple_device *mdev,
465
				   char *recvbuf)
466
{
467 468 469 470 471 472 473 474 475 476 477 478
	char submask;
	if ((!started) || (scanning == 2)) {
		maple_attach_driver(mdev);
		return;
	}
	if (mdev->unit == 0) {
		submask = recvbuf[2] & 0x1F;
		if (submask ^ subdevice_map[mdev->port]) {
			maple_map_subunits(mdev, submask);
			subdevice_map[mdev->port] = submask;
		}
	}
479 480 481 482 483
}

/* maple dma end bottom half - implemented via workqueue */
static void maple_dma_handler(struct work_struct *work)
{
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
	struct mapleq *mq, *nmq;
	struct maple_device *dev;
	char *recvbuf;
	enum maple_code code;

	if (!maple_dma_done())
		return;
	ctrl_outl(0, MAPLE_ENABLE);
	if (!list_empty(&maple_sentq)) {
		list_for_each_entry_safe(mq, nmq, &maple_sentq, list) {
			recvbuf = mq->recvbuf;
			code = recvbuf[0];
			dev = mq->dev;
			switch (code) {
			case MAPLE_RESPONSE_NONE:
				maple_response_none(dev, mq);
				break;

			case MAPLE_RESPONSE_DEVINFO:
				maple_response_devinfo(dev, recvbuf);
				break;

			case MAPLE_RESPONSE_DATATRF:
				if (dev->callback)
					dev->callback(mq);
				break;

			case MAPLE_RESPONSE_FILEERR:
			case MAPLE_RESPONSE_AGAIN:
			case MAPLE_RESPONSE_BADCMD:
			case MAPLE_RESPONSE_BADFUNC:
				printk(KERN_DEBUG
				       "Maple non-fatal error 0x%X\n",
				       code);
				break;

			case MAPLE_RESPONSE_ALLINFO:
				printk(KERN_DEBUG
				       "Maple - extended device information not supported\n");
				break;

			case MAPLE_RESPONSE_OK:
				break;

			default:
				break;
			}
		}
		INIT_LIST_HEAD(&maple_sentq);
		if (scanning == 1) {
			maple_send();
			scanning = 2;
		} else
			scanning = 0;

		if (started == 0)
			started = 1;
	}
	maplebus_dma_reset();
543 544 545 546
}

static irqreturn_t maplebus_dma_interrupt(int irq, void *dev_id)
{
547 548 549
	/* Load everything into the bottom half */
	schedule_work(&maple_dma_process);
	return IRQ_HANDLED;
550 551 552 553
}

static irqreturn_t maplebus_vblank_interrupt(int irq, void *dev_id)
{
554 555
	schedule_work(&maple_vblank_process);
	return IRQ_HANDLED;
556 557 558
}

static struct irqaction maple_dma_irq = {
559 560 561
	.name = "maple bus DMA handler",
	.handler = maplebus_dma_interrupt,
	.flags = IRQF_SHARED,
562 563 564
};

static struct irqaction maple_vblank_irq = {
565 566 567
	.name = "maple bus VBLANK handler",
	.handler = maplebus_vblank_interrupt,
	.flags = IRQF_SHARED,
568 569 570 571
};

static int maple_set_dma_interrupt_handler(void)
{
572
	return setup_irq(HW_EVENT_MAPLE_DMA, &maple_dma_irq);
573 574 575 576
}

static int maple_set_vblank_interrupt_handler(void)
{
577
	return setup_irq(HW_EVENT_VSYNC, &maple_vblank_irq);
578 579 580 581
}

static int maple_get_dma_buffer(void)
{
582 583 584 585 586 587
	maple_sendbuf =
	    (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO,
				      MAPLE_DMA_PAGES);
	if (!maple_sendbuf)
		return -ENOMEM;
	return 0;
588 589 590
}

static int match_maple_bus_driver(struct device *devptr,
591
				  struct device_driver *drvptr)
592
{
593 594 595 596 597 598 599 600 601 602 603 604
	struct maple_driver *maple_drv;
	struct maple_device *maple_dev;

	maple_drv = container_of(drvptr, struct maple_driver, drv);
	maple_dev = container_of(devptr, struct maple_device, dev);
	/* Trap empty port case */
	if (maple_dev->devinfo.function == 0xFFFFFFFF)
		return 0;
	else if (maple_dev->devinfo.function &
		 be32_to_cpu(maple_drv->function))
		return 1;
	return 0;
605 606
}

607 608
static int maple_bus_uevent(struct device *dev,
			    struct kobj_uevent_env *env)
609
{
610
	return 0;
611 612 613 614 615 616 617
}

static void maple_bus_release(struct device *dev)
{
}

static struct maple_driver maple_dummy_driver = {
618 619 620 621
	.drv = {
		.name = "maple_dummy_driver",
		.bus = &maple_bus_type,
		},
622 623 624
};

struct bus_type maple_bus_type = {
625 626 627
	.name = "maple",
	.match = match_maple_bus_driver,
	.uevent = maple_bus_uevent,
628
};
629

630 631 632
EXPORT_SYMBOL_GPL(maple_bus_type);

static struct device maple_bus = {
633 634
	.bus_id = "maple",
	.release = maple_bus_release,
635 636 637 638
};

static int __init maple_bus_init(void)
{
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737
	int retval, i;
	struct maple_device *mdev[MAPLE_PORTS];
	ctrl_outl(0, MAPLE_STATE);

	retval = device_register(&maple_bus);
	if (retval)
		goto cleanup;

	retval = bus_register(&maple_bus_type);
	if (retval)
		goto cleanup_device;

	retval = driver_register(&maple_dummy_driver.drv);

	if (retval)
		goto cleanup_bus;

	/* allocate memory for maple bus dma */
	retval = maple_get_dma_buffer();
	if (retval) {
		printk(KERN_INFO
		       "Maple bus: Failed to allocate Maple DMA buffers\n");
		goto cleanup_basic;
	}

	/* set up DMA interrupt handler */
	retval = maple_set_dma_interrupt_handler();
	if (retval) {
		printk(KERN_INFO
		       "Maple bus: Failed to grab maple DMA IRQ\n");
		goto cleanup_dma;
	}

	/* set up VBLANK interrupt handler */
	retval = maple_set_vblank_interrupt_handler();
	if (retval) {
		printk(KERN_INFO "Maple bus: Failed to grab VBLANK IRQ\n");
		goto cleanup_irq;
	}

	maple_queue_cache =
	    kmem_cache_create("maple_queue_cache", 0x400, 0,
			      SLAB_HWCACHE_ALIGN, NULL);

	if (!maple_queue_cache)
		goto cleanup_bothirqs;

	/* setup maple ports */
	for (i = 0; i < MAPLE_PORTS; i++) {
		mdev[i] = maple_alloc_dev(i, 0);
		if (!mdev[i]) {
			while (i-- > 0)
				maple_free_dev(mdev[i]);
			goto cleanup_cache;
		}
		mdev[i]->registered = 0;
		mdev[i]->mq->command = MAPLE_COMMAND_DEVINFO;
		mdev[i]->mq->length = 0;
		maple_attach_driver(mdev[i]);
		maple_add_packet(mdev[i]->mq);
		subdevice_map[i] = 0;
	}

	/* setup maplebus hardware */
	maplebus_dma_reset();

	/* initial detection */
	maple_send();

	maple_pnp_time = jiffies;

	printk(KERN_INFO "Maple bus core now registered.\n");

	return 0;

      cleanup_cache:
	kmem_cache_destroy(maple_queue_cache);

      cleanup_bothirqs:
	free_irq(HW_EVENT_VSYNC, 0);

      cleanup_irq:
	free_irq(HW_EVENT_MAPLE_DMA, 0);

      cleanup_dma:
	free_pages((unsigned long) maple_sendbuf, MAPLE_DMA_PAGES);

      cleanup_basic:
	driver_unregister(&maple_dummy_driver.drv);

      cleanup_bus:
	bus_unregister(&maple_bus_type);

      cleanup_device:
	device_unregister(&maple_bus);

      cleanup:
	printk(KERN_INFO "Maple bus registration failed\n");
	return retval;
738
}
739

740
subsys_initcall(maple_bus_init);