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