diff options
author | Kumar Gala <galak@freescale.com> | 2005-07-29 15:14:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-29 16:12:50 -0400 |
commit | cb14c3a13cb1e78acf54a9ddc9e5f3e2f023523e (patch) | |
tree | 0e301855624c19d120eda907513012582d9bb157 /drivers/i2c/busses | |
parent | fc185d95ecf3ca62fa9afb5214a69b39060ff537 (diff) |
[PATCH] I2C-MPC: Restore code removed
I2C-MPC: Restore code removed
A previous patch to remove support for the OCP device model was way
to generious and moved some of the platform device model code, oops.
Signed-off-by: Kumar Gala <kumar.gala@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r-- | drivers/i2c/busses/i2c-mpc.c | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 9ad3e9262e8a..04adde62a003 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -382,6 +382,100 @@ static void __exit fsl_i2c_exit(void) | |||
382 | module_init(fsl_i2c_init); | 382 | module_init(fsl_i2c_init); |
383 | module_exit(fsl_i2c_exit); | 383 | module_exit(fsl_i2c_exit); |
384 | 384 | ||
385 | static int fsl_i2c_probe(struct device *device) | ||
386 | { | ||
387 | int result = 0; | ||
388 | struct mpc_i2c *i2c; | ||
389 | struct platform_device *pdev = to_platform_device(device); | ||
390 | struct fsl_i2c_platform_data *pdata; | ||
391 | struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
392 | |||
393 | pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data; | ||
394 | |||
395 | if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) { | ||
396 | return -ENOMEM; | ||
397 | } | ||
398 | memset(i2c, 0, sizeof(*i2c)); | ||
399 | |||
400 | i2c->irq = platform_get_irq(pdev, 0); | ||
401 | i2c->flags = pdata->device_flags; | ||
402 | init_waitqueue_head(&i2c->queue); | ||
403 | |||
404 | i2c->base = ioremap((phys_addr_t)r->start, MPC_I2C_REGION); | ||
405 | |||
406 | if (!i2c->base) { | ||
407 | printk(KERN_ERR "i2c-mpc - failed to map controller\n"); | ||
408 | result = -ENOMEM; | ||
409 | goto fail_map; | ||
410 | } | ||
411 | |||
412 | if (i2c->irq != 0) | ||
413 | if ((result = request_irq(i2c->irq, mpc_i2c_isr, | ||
414 | SA_SHIRQ, "i2c-mpc", i2c)) < 0) { | ||
415 | printk(KERN_ERR | ||
416 | "i2c-mpc - failed to attach interrupt\n"); | ||
417 | goto fail_irq; | ||
418 | } | ||
419 | |||
420 | mpc_i2c_setclock(i2c); | ||
421 | dev_set_drvdata(device, i2c); | ||
422 | |||
423 | i2c->adap = mpc_ops; | ||
424 | i2c_set_adapdata(&i2c->adap, i2c); | ||
425 | i2c->adap.dev.parent = &pdev->dev; | ||
426 | if ((result = i2c_add_adapter(&i2c->adap)) < 0) { | ||
427 | printk(KERN_ERR "i2c-mpc - failed to add adapter\n"); | ||
428 | goto fail_add; | ||
429 | } | ||
430 | |||
431 | return result; | ||
432 | |||
433 | fail_add: | ||
434 | if (i2c->irq != 0) | ||
435 | free_irq(i2c->irq, NULL); | ||
436 | fail_irq: | ||
437 | iounmap(i2c->base); | ||
438 | fail_map: | ||
439 | kfree(i2c); | ||
440 | return result; | ||
441 | }; | ||
442 | |||
443 | static int fsl_i2c_remove(struct device *device) | ||
444 | { | ||
445 | struct mpc_i2c *i2c = dev_get_drvdata(device); | ||
446 | |||
447 | i2c_del_adapter(&i2c->adap); | ||
448 | dev_set_drvdata(device, NULL); | ||
449 | |||
450 | if (i2c->irq != 0) | ||
451 | free_irq(i2c->irq, i2c); | ||
452 | |||
453 | iounmap(i2c->base); | ||
454 | kfree(i2c); | ||
455 | return 0; | ||
456 | }; | ||
457 | |||
458 | /* Structure for a device driver */ | ||
459 | static struct device_driver fsl_i2c_driver = { | ||
460 | .name = "fsl-i2c", | ||
461 | .bus = &platform_bus_type, | ||
462 | .probe = fsl_i2c_probe, | ||
463 | .remove = fsl_i2c_remove, | ||
464 | }; | ||
465 | |||
466 | static int __init fsl_i2c_init(void) | ||
467 | { | ||
468 | return driver_register(&fsl_i2c_driver); | ||
469 | } | ||
470 | |||
471 | static void __exit fsl_i2c_exit(void) | ||
472 | { | ||
473 | driver_unregister(&fsl_i2c_driver); | ||
474 | } | ||
475 | |||
476 | module_init(fsl_i2c_init); | ||
477 | module_exit(fsl_i2c_exit); | ||
478 | |||
385 | MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>"); | 479 | MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>"); |
386 | MODULE_DESCRIPTION | 480 | MODULE_DESCRIPTION |
387 | ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors"); | 481 | ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors"); |