i2c-ocores 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. Kernel driver i2c-ocores
  2. Supported adapters:
  3. * OpenCores.org I2C controller by Richard Herveille (see datasheet link)
  4. Datasheet: http://www.opencores.org/projects.cgi/web/i2c/overview
  5. Author: Peter Korsgaard <jacmet@sunsite.dk>
  6. Description
  7. -----------
  8. i2c-ocores is an i2c bus driver for the OpenCores.org I2C controller
  9. IP core by Richard Herveille.
  10. Usage
  11. -----
  12. i2c-ocores uses the platform bus, so you need to provide a struct
  13. platform_device with the base address and interrupt number. The
  14. dev.platform_data of the device should also point to a struct
  15. ocores_i2c_platform_data (see linux/i2c-ocores.h) describing the
  16. distance between registers and the input clock speed.
  17. There is also a possibility to attach a list of i2c_board_info which
  18. the i2c-ocores driver will add to the bus upon creation.
  19. E.G. something like:
  20. static struct resource ocores_resources[] = {
  21. [0] = {
  22. .start = MYI2C_BASEADDR,
  23. .end = MYI2C_BASEADDR + 8,
  24. .flags = IORESOURCE_MEM,
  25. },
  26. [1] = {
  27. .start = MYI2C_IRQ,
  28. .end = MYI2C_IRQ,
  29. .flags = IORESOURCE_IRQ,
  30. },
  31. };
  32. /* optional board info */
  33. struct i2c_board_info ocores_i2c_board_info[] = {
  34. {
  35. I2C_BOARD_INFO("tsc2003", 0x48),
  36. .platform_data = &tsc2003_platform_data,
  37. .irq = TSC_IRQ
  38. },
  39. {
  40. I2C_BOARD_INFO("adv7180", 0x42 >> 1),
  41. .irq = ADV_IRQ
  42. }
  43. };
  44. static struct ocores_i2c_platform_data myi2c_data = {
  45. .regstep = 2, /* two bytes between registers */
  46. .clock_khz = 50000, /* input clock of 50MHz */
  47. .devices = ocores_i2c_board_info, /* optional table of devices */
  48. .num_devices = ARRAY_SIZE(ocores_i2c_board_info), /* table size */
  49. };
  50. static struct platform_device myi2c = {
  51. .name = "ocores-i2c",
  52. .dev = {
  53. .platform_data = &myi2c_data,
  54. },
  55. .num_resources = ARRAY_SIZE(ocores_resources),
  56. .resource = ocores_resources,
  57. };