aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-mpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses/i2c-mpc.c')
-rw-r--r--drivers/i2c/busses/i2c-mpc.c204
1 files changed, 0 insertions, 204 deletions
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index d41ca31dbcb2..03c23ce98edb 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -20,13 +20,7 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <asm/io.h> 22#include <asm/io.h>
23#ifdef CONFIG_FSL_OCP
24#include <asm/ocp.h>
25#define FSL_I2C_DEV_SEPARATE_DFSRR FS_I2C_SEPARATE_DFSRR
26#define FSL_I2C_DEV_CLOCK_5200 FS_I2C_CLOCK_5200
27#else
28#include <linux/fsl_devices.h> 23#include <linux/fsl_devices.h>
29#endif
30#include <linux/i2c.h> 24#include <linux/i2c.h>
31#include <linux/interrupt.h> 25#include <linux/interrupt.h>
32#include <linux/delay.h> 26#include <linux/delay.h>
@@ -294,204 +288,6 @@ static struct i2c_adapter mpc_ops = {
294 .retries = 1 288 .retries = 1
295}; 289};
296 290
297#ifdef CONFIG_FSL_OCP
298static int __devinit mpc_i2c_probe(struct ocp_device *ocp)
299{
300 int result = 0;
301 struct mpc_i2c *i2c;
302
303 if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) {
304 return -ENOMEM;
305 }
306 memset(i2c, 0, sizeof(*i2c));
307
308 i2c->irq = ocp->def->irq;
309 i2c->flags = ((struct ocp_fs_i2c_data *)ocp->def->additions)->flags;
310 init_waitqueue_head(&i2c->queue);
311
312 if (!request_mem_region(ocp->def->paddr, MPC_I2C_REGION, "i2c-mpc")) {
313 printk(KERN_ERR "i2c-mpc - resource unavailable\n");
314 return -ENODEV;
315 }
316
317 i2c->base = ioremap(ocp->def->paddr, MPC_I2C_REGION);
318
319 if (!i2c->base) {
320 printk(KERN_ERR "i2c-mpc - failed to map controller\n");
321 result = -ENOMEM;
322 goto fail_map;
323 }
324
325 if (i2c->irq != OCP_IRQ_NA)
326 {
327 if ((result = request_irq(ocp->def->irq, mpc_i2c_isr,
328 SA_SHIRQ, "i2c-mpc", i2c)) < 0) {
329 printk(KERN_ERR
330 "i2c-mpc - failed to attach interrupt\n");
331 goto fail_irq;
332 }
333 } else
334 i2c->irq = 0;
335
336 mpc_i2c_setclock(i2c);
337 ocp_set_drvdata(ocp, i2c);
338
339 i2c->adap = mpc_ops;
340 i2c_set_adapdata(&i2c->adap, i2c);
341
342 if ((result = i2c_add_adapter(&i2c->adap)) < 0) {
343 printk(KERN_ERR "i2c-mpc - failed to add adapter\n");
344 goto fail_add;
345 }
346
347 return result;
348
349 fail_add:
350 if (ocp->def->irq != OCP_IRQ_NA)
351 free_irq(ocp->def->irq, 0);
352 fail_irq:
353 iounmap(i2c->base);
354 fail_map:
355 release_mem_region(ocp->def->paddr, MPC_I2C_REGION);
356 kfree(i2c);
357 return result;
358}
359static void __devexit mpc_i2c_remove(struct ocp_device *ocp)
360{
361 struct mpc_i2c *i2c = ocp_get_drvdata(ocp);
362 i2c_del_adapter(&i2c->adap);
363 ocp_set_drvdata(ocp, NULL);
364
365 if (ocp->def->irq != OCP_IRQ_NA)
366 free_irq(i2c->irq, i2c);
367 iounmap(i2c->base);
368 release_mem_region(ocp->def->paddr, MPC_I2C_REGION);
369 kfree(i2c);
370}
371
372static struct ocp_device_id mpc_iic_ids[] __devinitdata = {
373 {.vendor = OCP_VENDOR_FREESCALE,.function = OCP_FUNC_IIC},
374 {.vendor = OCP_VENDOR_INVALID}
375};
376
377MODULE_DEVICE_TABLE(ocp, mpc_iic_ids);
378
379static struct ocp_driver mpc_iic_driver = {
380 .name = "iic",
381 .id_table = mpc_iic_ids,
382 .probe = mpc_i2c_probe,
383 .remove = __devexit_p(mpc_i2c_remove)
384};
385
386static int __init iic_init(void)
387{
388 return ocp_register_driver(&mpc_iic_driver);
389}
390
391static void __exit iic_exit(void)
392{
393 ocp_unregister_driver(&mpc_iic_driver);
394}
395
396module_init(iic_init);
397module_exit(iic_exit);
398#else
399static int fsl_i2c_probe(struct device *device)
400{
401 int result = 0;
402 struct mpc_i2c *i2c;
403 struct platform_device *pdev = to_platform_device(device);
404 struct fsl_i2c_platform_data *pdata;
405 struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
406
407 pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data;
408
409 if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) {
410 return -ENOMEM;
411 }
412 memset(i2c, 0, sizeof(*i2c));
413
414 i2c->irq = platform_get_irq(pdev, 0);
415 i2c->flags = pdata->device_flags;
416 init_waitqueue_head(&i2c->queue);
417
418 i2c->base = ioremap((phys_addr_t)r->start, MPC_I2C_REGION);
419
420 if (!i2c->base) {
421 printk(KERN_ERR "i2c-mpc - failed to map controller\n");
422 result = -ENOMEM;
423 goto fail_map;
424 }
425
426 if (i2c->irq != 0)
427 if ((result = request_irq(i2c->irq, mpc_i2c_isr,
428 SA_SHIRQ, "i2c-mpc", i2c)) < 0) {
429 printk(KERN_ERR
430 "i2c-mpc - failed to attach interrupt\n");
431 goto fail_irq;
432 }
433
434 mpc_i2c_setclock(i2c);
435 dev_set_drvdata(device, i2c);
436
437 i2c->adap = mpc_ops;
438 i2c_set_adapdata(&i2c->adap, i2c);
439 i2c->adap.dev.parent = &pdev->dev;
440 if ((result = i2c_add_adapter(&i2c->adap)) < 0) {
441 printk(KERN_ERR "i2c-mpc - failed to add adapter\n");
442 goto fail_add;
443 }
444
445 return result;
446
447 fail_add:
448 if (i2c->irq != 0)
449 free_irq(i2c->irq, NULL);
450 fail_irq:
451 iounmap(i2c->base);
452 fail_map:
453 kfree(i2c);
454 return result;
455};
456
457static int fsl_i2c_remove(struct device *device)
458{
459 struct mpc_i2c *i2c = dev_get_drvdata(device);
460
461 i2c_del_adapter(&i2c->adap);
462 dev_set_drvdata(device, NULL);
463
464 if (i2c->irq != 0)
465 free_irq(i2c->irq, i2c);
466
467 iounmap(i2c->base);
468 kfree(i2c);
469 return 0;
470};
471
472/* Structure for a device driver */
473static struct device_driver fsl_i2c_driver = {
474 .name = "fsl-i2c",
475 .bus = &platform_bus_type,
476 .probe = fsl_i2c_probe,
477 .remove = fsl_i2c_remove,
478};
479
480static int __init fsl_i2c_init(void)
481{
482 return driver_register(&fsl_i2c_driver);
483}
484
485static void __exit fsl_i2c_exit(void)
486{
487 driver_unregister(&fsl_i2c_driver);
488}
489
490module_init(fsl_i2c_init);
491module_exit(fsl_i2c_exit);
492
493#endif /* CONFIG_FSL_OCP */
494
495MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>"); 291MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>");
496MODULE_DESCRIPTION 292MODULE_DESCRIPTION
497 ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors"); 293 ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors");