* [PATCH] Documentation: EEPROM: add kernel side usage description
@ 2012-01-25 11:12 Yegor Yefremov
[not found] ` <4F1FE390.6040903-ZJVcf1zZPRSebONBosFW4Q@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Yegor Yefremov @ 2012-01-25 11:12 UTC (permalink / raw)
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
Cc: Wolfram Sang, khali-PUYAD+kWke1g9hUCZPvPmw
add EEPROM usage instructions and example for kernel side.
dm644x-evm was taken as example.
Signed-off-by: Yegor Yefremov <yegorslists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
---
Documentation/misc-devices/eeprom | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
Index: b/Documentation/misc-devices/eeprom
===================================================================
--- a/Documentation/misc-devices/eeprom
+++ b/Documentation/misc-devices/eeprom
@@ -90,7 +90,41 @@
Use:
+1. Userland
+
After inserting the module (and any other required SMBus/i2c modules), you
should have some EEPROM directories in /sys/bus/i2c/devices/* of names such
as "0-0050". Inside each of these is a series of files, the eeprom file
contains the binary data from EEPROM.
+
+2. Kernel
+
+It is also possible to read/write EEPROM from kernel side. at24.c provides two
+routines at24_macc_read() and at24_macc_write(). Those routines can be used
+as part of setup() routine, when configuring platform data for i2c EEPROM.
+
+Example:
+
+arch/arm/mach-davinci/board-dm644x-evm.c uses EEPROM to store MAC address.
+This is how EEPROM platform data will be set up:
+
+static struct at24_platform_data eeprom_info = {
+ .byte_len = (256*1024) / 8,
+ .page_size = 64,
+ .flags = AT24_FLAG_ADDR16,
+ .setup = davinci_get_mac_addr,
+ .context = (void *)0x7f00,
+};
+
+davinci_get_mac_addr() will be called from at24_probe() and fetches the MAC
+address from specified offset:
+
+void davinci_get_mac_addr(struct memory_accessor *mem_acc, void *context)
+{
+ char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
+ off_t offset = (off_t)context;
+
+ /* Read MAC addr from EEPROM */
+ if (mem_acc->read(mem_acc, mac_addr, offset, ETH_ALEN) == ETH_ALEN)
+ pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Documentation: EEPROM: add kernel side usage description
[not found] ` <4F1FE390.6040903-ZJVcf1zZPRSebONBosFW4Q@public.gmane.org>
@ 2012-01-25 14:28 ` Wolfram Sang
0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2012-01-25 14:28 UTC (permalink / raw)
To: Yegor Yefremov
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, khali-PUYAD+kWke1g9hUCZPvPmw
[-- Attachment #1: Type: text/plain, Size: 606 bytes --]
On Wed, Jan 25, 2012 at 12:12:16PM +0100, Yegor Yefremov wrote:
> add EEPROM usage instructions and example for kernel side.
> dm644x-evm was taken as example.
>
> Signed-off-by: Yegor Yefremov <yegorslists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
Good idea, only this file describes eeprom.c not at24.c. eeprom.c is
deprecated. I'd suggest to add the usage example for macc to the at24
source code, after the comment I pointed you to.
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-25 14:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-25 11:12 [PATCH] Documentation: EEPROM: add kernel side usage description Yegor Yefremov
[not found] ` <4F1FE390.6040903-ZJVcf1zZPRSebONBosFW4Q@public.gmane.org>
2012-01-25 14:28 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).