i2c-ocores.rst 1.8 KB

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