at24.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * at24.h - platform_data for the at24 (generic eeprom) driver
  3. * (C) Copyright 2008 by Pengutronix
  4. * (C) Copyright 2012 by Wolfram Sang
  5. * same license as the driver
  6. */
  7. #ifndef _LINUX_AT24_H
  8. #define _LINUX_AT24_H
  9. #include <linux/types.h>
  10. #include <linux/memory.h>
  11. /**
  12. * struct at24_platform_data - data to set up at24 (generic eeprom) driver
  13. * @byte_len: size of eeprom in byte
  14. * @page_size: number of byte which can be written in one go
  15. * @flags: tunable options, check AT24_FLAG_* defines
  16. * @setup: an optional callback invoked after eeprom is probed; enables kernel
  17. code to access eeprom via memory_accessor, see example
  18. * @context: optional parameter passed to setup()
  19. *
  20. * If you set up a custom eeprom type, please double-check the parameters.
  21. * Especially page_size needs extra care, as you risk data loss if your value
  22. * is bigger than what the chip actually supports!
  23. *
  24. * An example in pseudo code for a setup() callback:
  25. *
  26. * void get_mac_addr(struct memory_accessor *mem_acc, void *context)
  27. * {
  28. * u8 *mac_addr = ethernet_pdata->mac_addr;
  29. * off_t offset = context;
  30. *
  31. * // Read MAC addr from EEPROM
  32. * if (mem_acc->read(mem_acc, mac_addr, offset, ETH_ALEN) == ETH_ALEN)
  33. * pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
  34. * }
  35. *
  36. * This function pointer and context can now be set up in at24_platform_data.
  37. */
  38. struct at24_platform_data {
  39. u32 byte_len; /* size (sum of all addr) */
  40. u16 page_size; /* for writes */
  41. u8 flags;
  42. #define AT24_FLAG_ADDR16 0x80 /* address pointer is 16 bit */
  43. #define AT24_FLAG_READONLY 0x40 /* sysfs-entry will be read-only */
  44. #define AT24_FLAG_IRUGO 0x20 /* sysfs-entry will be world-readable */
  45. #define AT24_FLAG_TAKE8ADDR 0x10 /* take always 8 addresses (24c00) */
  46. void (*setup)(struct memory_accessor *, void *context);
  47. void *context;
  48. };
  49. #endif /* _LINUX_AT24_H */