i2c-ocores 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. E.G. something like:
  18. static struct resource ocores_resources[] = {
  19. [0] = {
  20. .start = MYI2C_BASEADDR,
  21. .end = MYI2C_BASEADDR + 8,
  22. .flags = IORESOURCE_MEM,
  23. },
  24. [1] = {
  25. .start = MYI2C_IRQ,
  26. .end = MYI2C_IRQ,
  27. .flags = IORESOURCE_IRQ,
  28. },
  29. };
  30. static struct ocores_i2c_platform_data myi2c_data = {
  31. .regstep = 2, /* two bytes between registers */
  32. .clock_khz = 50000, /* input clock of 50MHz */
  33. };
  34. static struct platform_device myi2c = {
  35. .name = "ocores-i2c",
  36. .dev = {
  37. .platform_data = &myi2c_data,
  38. },
  39. .num_resources = ARRAY_SIZE(ocores_resources),
  40. .resource = ocores_resources,
  41. };