i2c-rpx.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Embedded Planet RPX Lite MPC8xx CPM I2C interface.
  3. * Copyright (c) 1999 Dan Malek (dmalek@jlc.net).
  4. *
  5. * moved into proper i2c interface;
  6. * Brad Parker (brad@heeltoe.com)
  7. *
  8. * RPX lite specific parts of the i2c interface
  9. * Update: There actually isn't anything RPXLite-specific about this module.
  10. * This should work for most any 8xx board. The console messages have been
  11. * changed to eliminate RPXLite references.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <linux/init.h>
  16. #include <linux/stddef.h>
  17. #include <linux/i2c.h>
  18. #include <linux/i2c-algo-8xx.h>
  19. #include <asm/mpc8xx.h>
  20. #include <asm/commproc.h>
  21. static void
  22. rpx_iic_init(struct i2c_algo_8xx_data *data)
  23. {
  24. volatile cpm8xx_t *cp;
  25. volatile immap_t *immap;
  26. cp = cpmp; /* Get pointer to Communication Processor */
  27. immap = (immap_t *)IMAP_ADDR; /* and to internal registers */
  28. data->iip = (iic_t *)&cp->cp_dparam[PROFF_IIC];
  29. /* Check for and use a microcode relocation patch.
  30. */
  31. if ((data->reloc = data->iip->iic_rpbase))
  32. data->iip = (iic_t *)&cp->cp_dpmem[data->iip->iic_rpbase];
  33. data->i2c = (i2c8xx_t *)&(immap->im_i2c);
  34. data->cp = cp;
  35. /* Initialize Port B IIC pins.
  36. */
  37. cp->cp_pbpar |= 0x00000030;
  38. cp->cp_pbdir |= 0x00000030;
  39. cp->cp_pbodr |= 0x00000030;
  40. /* Allocate space for two transmit and two receive buffer
  41. * descriptors in the DP ram.
  42. */
  43. data->dp_addr = cpm_dpalloc(sizeof(cbd_t) * 4, 8);
  44. /* ptr to i2c area */
  45. data->i2c = (i2c8xx_t *)&(((immap_t *)IMAP_ADDR)->im_i2c);
  46. }
  47. static int rpx_install_isr(int irq, void (*func)(void *, void *), void *data)
  48. {
  49. /* install interrupt handler */
  50. cpm_install_handler(irq, (void (*)(void *, struct pt_regs *)) func, data);
  51. return 0;
  52. }
  53. static struct i2c_algo_8xx_data rpx_data = {
  54. .setisr = rpx_install_isr
  55. };
  56. static struct i2c_adapter rpx_ops = {
  57. .owner = THIS_MODULE,
  58. .name = "m8xx",
  59. .id = I2C_HW_MPC8XX_EPON,
  60. .algo_data = &rpx_data,
  61. };
  62. int __init i2c_rpx_init(void)
  63. {
  64. printk(KERN_INFO "i2c-rpx: i2c MPC8xx driver\n");
  65. /* reset hardware to sane state */
  66. rpx_iic_init(&rpx_data);
  67. if (i2c_8xx_add_bus(&rpx_ops) < 0) {
  68. printk(KERN_ERR "i2c-rpx: Unable to register with I2C\n");
  69. return -ENODEV;
  70. }
  71. return 0;
  72. }
  73. void __exit i2c_rpx_exit(void)
  74. {
  75. i2c_8xx_del_bus(&rpx_ops);
  76. }
  77. MODULE_AUTHOR("Dan Malek <dmalek@jlc.net>");
  78. MODULE_DESCRIPTION("I2C-Bus adapter routines for MPC8xx boards");
  79. module_init(i2c_rpx_init);
  80. module_exit(i2c_rpx_exit);