Compare commits

...

47 Commits

Author SHA1 Message Date
Jean Delvare 96fca5cdb0 tools: Don't build with -Winline 5 years ago
Jean Delvare 11a1738e83 i2cset: Fix short writes with mask 5 years ago
Jean Delvare a5a59fb959 tools: i2cbusses: Check the return value of snprintf 8 years ago
Jean Delvare 7c71a78fb0 Consistently use snprintf instead of sprintf 7 years ago
Jean Delvare 07563e8ff8 i2c-tools: i2cbusses: Avoid buffer overflows in sysfs paths 8 years ago
Jean Delvare 3b194ddb8c Delete i2ctransfer 8 years ago
Ondřej Lysoněk 466bb8cb49 py-smbus: Fix FSF address in smbusmodule.c 8 years ago
Stefan Agner d4b95a31cd eeprog: Increase sleep between byte writes 8 years ago
Jean Delvare ba2abe60bd Add missing man page cross-references 8 years ago
Jean Delvare 4fbf2b6737 Drop stray references to lm-sensors.org 8 years ago
Jean Delvare 152c44190e Mention the current maintainer 11 years ago
Wolfram Sang c1ea203e35 i2c-tools: add new tool 'i2ctransfer' 11 years ago
Wolfram Sang 58ebb2f385 i2c-tools: add .gitignore 9 years ago
Wolfram Sang 119a811034 i2c-tools: fix feature test macros for glibc >= 2.20 9 years ago
Jean Delvare dc95875dbc Drop obsolete SVN keywords 9 years ago
Jean Delvare 2b4135907c decode-dimms: Correctly check for out-of-bounds vendor ID 9 years ago
Jean Delvare 62cbc64c4f Set version to 3.1.2. 9 years ago
Jean Delvare 824de0ae34 py-smbus: Add support for python 3 9 years ago
Jean Delvare b9cf0129a9 decode-dimms: Fix DDR3 extended temp range refresh rate decoding 9 years ago
Jean Delvare d58c9009c7 Set version to 3.1.1. 12 years ago
Jean Delvare 05f1a6485f Manual pages for eeprog, eeprom and eepromer, contributed by Jaromir 12 years ago
Jean Delvare 96d275f6eb Add manual pages for decode-dimms and decode-vaio 12 years ago
Jean Delvare e32987a243 py-smbus: fix module level docs 12 years ago
Jean Delvare 95674a88a5 decode-dimms: Encode "degrees" to HTML degree symbol 12 years ago
Jean Delvare a94388357b Fix potential build error (NULL undefined) caused by missing include file 12 years ago
Jean Delvare f8de12205f Delete empty file and directory 12 years ago
Jean Delvare a0d9fb99f8 i2c-dev: Revert most of r6048 and r6052 12 years ago
Jean Delvare e67a49f679 ddcmon: Merge copyright information 12 years ago
Jean Delvare 2df6dcb997 Update my e-mail address and copyright years. 12 years ago
Jean Delvare ba1491d03d Add missing option -r to usage summary 12 years ago
Jean Delvare 407fc259e3 Doh. I've proofread these names twice and even that was not enough :( 12 years ago
Jean Delvare bfd0e2e24a Add manufacturer names from Jedec document JEP106AK. 12 years ago
Jean Delvare 9b4e137eb1 decode-dimms: Fix typo in vendor name 12 years ago
Jean Delvare 4aa36fe574 DDR3: Round down PC3 numbers to comply with Jedec. 12 years ago
Jean Delvare cbfef7739d DDR3: Round core timings up, not down. 12 years ago
Jean Delvare 7add855d52 DDR3: Use the right nibble from byte 21 as the MSB of tRAS. 12 years ago
Jean Delvare eb2db47736 Print a space before "MHz" to improve readability. 12 years ago
Jean Delvare f8d5ac8396 Decode more DDR3 module types 13 years ago
Jean Delvare 7987d0d642 Prevent hang on reserved DDR3 module type 13 years ago
Jean Delvare e1974d0945 i2cdetect: Clarify the SMBus commands used for probing by default. 13 years ago
Jean Delvare 363d38f24a Fix decoding of SDR SPD revision. The encoding changed with revision 13 years ago
Jean Delvare 9dbd13a1f2 Remove duplicate "ns" in SDR timings. 13 years ago
Jean Delvare 0c6e11a7e8 Add manufacturer names from Jedec document JEP106AJ. 13 years ago
Jean Delvare 5e46bf8d31 Update vendor list based on Jedec document JEP106AG. Contributed by 13 years ago
Jean Delvare 242b1c714c Don't choke when no SPD EEPROM is found while the eeprom or at24 driver 13 years ago
Jean Delvare 14691e91df Add header file missed from a previous commit. 13 years ago
Jean Delvare 495e59f96b i2c-tools version 3 goes to maintenance mode 13 years ago
  1. 8
      .gitignore
  2. 32
      CHANGES
  3. 2
      Makefile
  4. 5
      README
  5. 1
      eeprog/.gitignore
  6. 9
      eeprom/Module.mk
  7. 6
      eeprom/ddcmon
  8. 148
      eeprom/decode-dimms
  9. 67
      eeprom/decode-dimms.1
  10. 12
      eeprom/decode-edid
  11. 4
      eeprom/decode-vaio
  12. 35
      eeprom/decode-vaio.1
  13. 2
      eepromer/.gitignore
  14. 17
      eepromer/24cXX.c
  15. 2
      eepromer/24cXX.h
  16. 103
      eepromer/eeprog.8
  17. 2
      eepromer/eeprog.c
  18. 64
      eepromer/eeprom.8
  19. 1
      eepromer/eeprom.c
  20. 61
      eepromer/eepromer.8
  21. 1
      eepromer/eepromer.c
  22. 6
      include/Module.mk
  23. 258
      include/linux/i2c-dev.h
  24. 2
      py-smbus/Module.mk
  25. 2
      py-smbus/setup.py
  26. 54
      py-smbus/smbusmodule.c
  27. 2
      stub/Module.mk
  28. 2
      stub/i2c-stub-from-dump
  29. 4
      tools/.gitignore
  30. 14
      tools/Module.mk
  31. 55
      tools/i2cbusses.c
  32. 2
      tools/i2cbusses.h
  33. 14
      tools/i2cdetect.8
  34. 4
      tools/i2cdetect.c
  35. 2
      tools/i2cdump.8
  36. 4
      tools/i2cdump.c
  37. 2
      tools/i2cget.8
  38. 6
      tools/i2cget.c
  39. 2
      tools/i2cset.8
  40. 31
      tools/i2cset.c
  41. 2
      tools/util.c
  42. 2
      tools/util.h
  43. 2
      version.h

8
.gitignore

@ -0,0 +1,8 @@
.*
*.o
*.o.*
*.a
*.so
*.so.*
*.so.dbg
*.ao

32
CHANGES

@ -1,12 +1,40 @@
i2c-tools CHANGES
-----------------
SVN HEAD
3.1.3 (work in progress)
Makefile: Don't build tools with -Winline
tools: Fix potential buffer overflows in i2cbusses
eeprog: Increase delay after writes
decode-dimms: Correctly check for out-of-bounds vendor ID
i2cset: Fix short writes with mask
README: Mention the current maintainer
3.1.2 (2015-06-17)
decode-dimms: Fix DDR3 extended temp range refresh rate decoding
py-smbus: Add support for python 3
3.1.1 "Happy Birthday Pollux" (2014-02-20)
decode-dimms: Decode module configuration type of DDR2 SDRAM
Decode bus width extension of DDR3 SDRAM
Don't choke when no EEPROM is found
Update manufacturer IDs
Remove duplicate "ns" in SDR timings
Fix decoding of SDR SPD revision
Prevent hang on reserved DDR3 module type
Decode more DDR3 module types
Fix DDR3 tRAS decoding
Fix DDR3 core timings rounding
Round down PC3 numbers to comply with Jedec
Encode "degrees" to HTML degree symbol
Add a manual page
decode-vaio: Add a manual page
eeprog: Add a manual page
eeprom: Add a manual page
eepromer: Add a manual page
i2cdetect: Clarify the SMBus commands used for probing by default
i2c-dev.h: Minimize differences with kernel flavor
Move SMBus helper functions to include/i2c/smbus.h
i2c-stub-from-dump: Be more tolerant on input dump format
py-smbus: Fix module level docs
3.1.0 (2011-12-04)
decode-dimms: Decode module configuration type of DDR SDRAM

2
Makefile

@ -1,6 +1,6 @@
# I2C tools for Linux
#
# Copyright (C) 2007 Jean Delvare <khali@linux-fr.org>
# Copyright (C) 2007-2012 Jean Delvare <jdelvare@suse.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

5
README

@ -6,6 +6,9 @@ These tools were originally part of the lm-sensors project but were finally
split into their own package for convenience. They compile, run and have been
tested on GNU/Linux.
The latest version of the code can be downloaded from:
https://i2c.wiki.kernel.org/index.php/I2C_Tools
CONTENTS
--------
@ -72,5 +75,7 @@ QUESTIONS AND BUG REPORTS
Please post your questions and bug reports to the linux-i2c mailing list:
linux-i2c@vger.kernel.org
with Cc to the current maintainer:
Jean Delvare <jdelvare@suse.de>
For additional information about this list, see:
http://vger.kernel.org/vger-lists.html#linux-i2c

1
eeprog/.gitignore

@ -0,0 +1 @@
/eeprog

9
eeprom/Module.mk

@ -1,6 +1,6 @@
# EEPROM decoding scripts for the Linux eeprom driver
#
# Copyright (C) 2007-2008 Jean Delvare <khali@linux-fr.org>
# Copyright (C) 2007-2013 Jean Delvare <jdelvare@suse.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -10,19 +10,24 @@
EEPROM_DIR := eeprom
EEPROM_TARGETS := decode-dimms decode-vaio ddcmon decode-edid
EEPROM_MANPAGES := decode-dimms.1 decode-vaio.1
#
# Commands
#
install-eeprom: $(addprefix $(EEPROM_DIR)/,$(EEPROM_TARGETS))
$(INSTALL_DIR) $(DESTDIR)$(bindir)
$(INSTALL_DIR) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1
for program in $(EEPROM_TARGETS) ; do \
$(INSTALL_PROGRAM) $(EEPROM_DIR)/$$program $(DESTDIR)$(bindir) ; done
for manual in $(EEPROM_MANPAGES) ; do \
$(INSTALL_DATA) $(EEPROM_DIR)/$$manual $(DESTDIR)$(mandir)/man1 ; done
uninstall-eeprom:
for program in $(EEPROM_TARGETS) ; do \
$(RM) $(DESTDIR)$(bindir)/$$program ; done
for manual in $(EEPROM_MANPAGES) ; do \
$(RM) $(DESTDIR)$(mandir)/$$manual ; done
install: install-eeprom

6
eeprom/ddcmon

@ -1,9 +1,9 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2004-2005 Jean Delvare <khali@linux-fr.org>
# Copyright (C) 2004-2008 Jean Delvare <jdelvare@suse.de>
#
# Parts inspired from decode-edid.
# Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org>
# Copyright (C) 2003-2004 Jean Delvare
#
# Parts inspired from the ddcmon driver and sensors' print_ddcmon function.
# Copyright (C) 1998-2004 Mark D. Studebaker
@ -26,8 +26,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.
#
# Version 1.0 2005-01-04 Jean Delvare <khali@linux-fr.org>
#
# This script is a replacement for the now deprecated ddcmon kernel driver.
# Instead of having a dedicated driver, it is better to reuse the standard
# eeprom driver and implement the EDID-specific code in user-space.

148
eeprom/decode-dimms

@ -5,7 +5,7 @@
# Copyright 1998, 1999 Philip Edelbrock <phil@netroedge.com>
# modified by Christian Zuckschwerdt <zany@triq.net>
# modified by Burkart Lingner <burkart@bollchen.de>
# Copyright (C) 2005-2011 Jean Delvare <khali@linux-fr.org>
# Copyright (C) 2005-2013 Jean Delvare <jdelvare@suse.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -64,17 +64,17 @@ $revision =~ s/ \([^()]*\)//;
"Lattice Semi.", "NCR", "Wafer Scale Integration", "IBM",
"Tristar", "Visic", "Intl. CMOS Technology", "SSSI",
"MicrochipTechnology", "Ricoh Ltd.", "VLSI", "Micron Technology",
"Hyundai Electronics", "OKI Semiconductor", "ACTEL", "Sharp",
"SK Hynix (former Hyundai Electronics)", "OKI Semiconductor", "ACTEL", "Sharp",
"Catalyst", "Panasonic", "IDT", "Cypress",
"DEC", "LSI Logic", "Zarlink (former Plessey)", "UTMC",
"Thinking Machine", "Thomson CSF", "Integrated CMOS (Vertex)", "Honeywell",
"Tektronix", "Sun Microsystems", "SST", "ProMos/Mosel Vitelic",
"Tektronix", "Oracle Corporation (former Sun Microsystems)", "Silicon Storage Technology", "ProMos/Mosel Vitelic",
"Infineon (former Siemens)", "Macronix", "Xerox", "Plus Logic",
"SunDisk", "Elan Circuit Tech.", "European Silicon Str.", "Apple Computer",
"Xilinx", "Compaq", "Protocol Engines", "SCI",
"Seiko Instruments", "Samsung", "I3 Design System", "Klic",
"Crosspoint Solutions", "Alliance Semiconductor", "Tandem", "Hewlett-Packard",
"Intg. Silicon Solutions", "Brooktree", "New Media", "MHS Electronic",
"Integrated Silicon Solutions", "Brooktree", "New Media", "MHS Electronic",
"Performance Semi.", "Winbond Electronic", "Kawasaki Steel", "Bright Micro",
"TECMAR", "Exar", "PCMCIA", "LG Semi (former Goldstar)",
"Northern Telecom", "Sanyo", "Array Microsystems", "Crystal Semiconductor",
@ -84,7 +84,7 @@ $revision =~ s/ \([^()]*\)//;
"Sony", "Cray Research", "AMS(Austria Micro)", "Vitesse",
"Aster Electronics", "Bay Networks (Synoptic)", "Zentrum or ZMD", "TRW",
"Thesys", "Solbourne Computer", "Allied-Signal", "Dialog",
"Media Vision", "Level One Communication"],
"Media Vision", "Numonyx Corporation (former Level One Communication)"],
["Cirrus Logic", "National Instruments", "ILC Data Device", "Alcatel Mietec",
"Micro Linear", "Univ. of NC", "JTAG Technologies", "BAE Systems",
"Nchip", "Galileo Tech", "Bestlink Systems", "Graychip",
@ -119,7 +119,7 @@ $revision =~ s/ \([^()]*\)//;
"Quadratics Superconductor", "3COM"],
["Camintonn Corporation", "ISOA Incorporated", "Agate Semiconductor", "ADMtek Incorporated",
"HYPERTEC", "Adhoc Technologies", "MOSAID Technologies", "Ardent Technologies",
"Switchcore", "Cisco Systems, Inc.", "Allayer Technologies", "WorkX AG",
"Switchcore", "Cisco Systems, Inc.", "Allayer Technologies", "WorkX AG (Wichman)",
"Oasis Semiconductor", "Novanet Semiconductor", "E-M Solutions", "Power General",
"Advanced Hardware Arch.", "Inova Semiconductors GmbH", "Telocity", "Delkin Devices",
"Symagery Microsystems", "C-Port Corporation", "SiberCore Technologies", "Southland Microsystems",
@ -129,7 +129,7 @@ $revision =~ s/ \([^()]*\)//;
"Chameleon Systems", "Aplus Flash Technology", "MIPS Technologies", "Chrysalis ITS",
"ADTEC Corporation", "Kentron Technologies", "Win Technologies", "Tachyon Semiconductor (former ASIC Designs Inc.)",
"Extreme Packet Devices", "RF Micro Devices", "Siemens AG", "Sarnoff Corporation",
"Itautec Philco SA", "Radiata Inc.", "Benchmark Elect. (AVEX)", "Legend",
"Itautec SA (former Itautec Philco SA)", "Radiata Inc.", "Benchmark Elect. (AVEX)", "Legend",
"SpecTek Incorporated", "Hi/fn", "Enikia Incorporated", "SwitchOn Networks",
"AANetcom Incorporated", "Micro Memory Bank", "ESS Technology", "Virata Corporation",
"Excess Bandwidth", "West Bay Semiconductor", "DSP Group", "Newport Communications",
@ -171,26 +171,26 @@ $revision =~ s/ \([^()]*\)//;
"PLX Technology", "Massana Design", "Intrinsity", "Valence Semiconductor",
"Terawave Communications", "IceFyre Semiconductor", "Primarion", "Picochip Designs Ltd",
"Silverback Systems", "Jade Star Technologies", "Pijnenburg Securealink",
"TakeMS International AG", "Cambridge Silicon Radio",
"takeMS - Ultron AG (former Memorysolution GmbH)", "Cambridge Silicon Radio",
"Swissbit", "Nazomi Communications", "eWave System",
"Rockwell Collins", "Picocel Co., Ltd.", "Alphamosaic Ltd", "Sandburst",
"SiCon Video", "NanoAmp Solutions", "Ericsson Technology", "PrairieComm",
"Mitac International", "Layer N Networks", "MtekVision", "Allegro Networks",
"Marvell Semiconductors", "Netergy Microelectronic", "NVIDIA", "Internet Machines",
"Peak Electronics", "Litchfield Communication", "Accton Technology", "Teradiant Networks",
"Europe Technologies", "Cortina Systems", "RAM Components", "Raqia Networks",
"Scaleo Chip (former Europe Technologies)", "Cortina Systems", "RAM Components", "Raqia Networks",
"ClearSpeed", "Matsushita Battery", "Xelerated", "SimpleTech",
"Utron Technology", "Astec International", "AVM gmbH", "Redux Communications",
"Dot Hill Systems", "TeraChip"],
["T-RAM Incorporated", "Innovics Wireless", "Teknovus", "KeyEye Communications",
"Runcom Technologies", "RedSwitch", "Dotcast", "Silicon Mountain Memory",
"Signia Technologies", "Pixim", "Galazar Networks", "White Electronic Designs",
"Patriot Scientific", "Neoaxiom Corporation", "3Y Power Technology", "Europe Technologies",
"Patriot Scientific", "Neoaxiom Corporation", "3Y Power Technology", "Scaleo Chip (former Europe Technologies)",
"Potentia Power Systems", "C-guys Incorporated", "Digital Communications Technology Incorporated", "Silicon-Based Technology",
"Fulcrum Microsystems", "Positivo Informatica Ltd", "XIOtech Corporation", "PortalPlayer",
"Zhiying Software", "Direct2Data", "Phonex Broadband", "Skyworks Solutions",
"Zhiying Software", "Parker Vision, Inc. (former Direct2Data)", "Phonex Broadband", "Skyworks Solutions",
"Entropic Communications", "Pacific Force Technology", "Zensys A/S", "Legend Silicon Corp.",
"sci-worx GmbH", "SMSC (former Oasis Silicon Systems)", "Renesas Technology", "Raza Microelectronics",
"sci-worx GmbH", "SMSC (former Oasis Silicon Systems)", "Renesas Electronics (former Renesas Technology)", "Raza Microelectronics",
"Phyworks", "MediaTek", "Non-cents Productions", "US Modular",
"Wintegra Ltd", "Mathstar", "StarCore", "Oplus Technologies",
"Mindspeed", "Just Young Computer", "Radia Communications", "OCZ",
@ -221,7 +221,7 @@ $revision =~ s/ \([^()]*\)//;
"g2 Microsystems", "PowerFlash Semiconductor", "P.A. Semi, Inc.", "NovaTech Solutions, S.A.",
"c2 Microsystems, Inc.", "Level5 Networks", "COS Memory AG", "Innovasic Semiconductor",
"02IC Co. Ltd", "Tabula, Inc.", "Crucial Technology", "Chelsio Communications",
"Solarflare Communications", "Xambala Inc.", "EADS Astrium", "ATO Semicon Co. Ltd.",
"Solarflare Communications", "Xambala Inc.", "EADS Astrium", "Terra Semiconductor Inc. (former ATO Semicon Co. Ltd.)",
"Imaging Works, Inc.", "Astute Networks, Inc.", "Tzero", "Emulex",
"Power-One", "Pulse~LINK Inc.", "Hon Hai Precision Industry", "White Rock Networks Inc.",
"Telegent Systems USA, Inc.", "Atrua Technologies, Inc.", "Acbel Polytech Inc.",
@ -251,7 +251,59 @@ $revision =~ s/ \([^()]*\)//;
"Tec-Hill", "Multigig, Inc.", "Amimon", "Euphonic Technologies, Inc.", "BRN Phoenix",
"InSilica", "Ember Corporation", "Avexir Technologies Corporation", "Echelon Corporation",
"Edgewater Computer Systems", "XMOS Semiconductor Ltd.", "GENUSION, Inc.", "Memory Corp NV",
"SiliconBlue Technologies", "Rambus Inc."]);
"SiliconBlue Technologies", "Rambus Inc.", "Andes Technology Corporation", "Coronis Systems",
"Achronix Semiconductor", "Siano Mobile Silicon Ltd.", "Semtech Corporation", "Pixelworks Inc.",
"Gaisler Research AB", "Teranetics", "Toppan Printing Co. Ltd.", "Kingxcon",
"Silicon Integrated Systems", "I-O Data Device, Inc.", "NDS Americas Inc.", "Solomon Systech Limited",
"On Demand Microelectronics", "Amicus Wireless Inc.", "SMARDTV SNC", "Comsys Communication Ltd.",
"Movidia Ltd.", "Javad GNSS, Inc.", "Montage Technology Group", "Trident Microsystems", "Super Talent",
"Optichron, Inc.", "Future Waves UK Ltd.", "SiBEAM, Inc.", "Inicore, Inc.", "Virident Systems",
"M2000, Inc.", "ZeroG Wireless, Inc.", "Gingle Technology Co. Ltd.", "Space Micro Inc.", "Wilocity",
"Novafora, Inc.", "iKoa Corporation", "ASint Technology", "Ramtron", "Plato Networks Inc.",
"IPtronics AS", "Infinite-Memories", "Parade Technologies Inc.", "Dune Networks",
"GigaDevice Semiconductor", "Modu Ltd.", "CEITEC", "Northrop Grumman", "XRONET Corporation",
"Sicon Semiconductor AB", "Atla Electronics Co. Ltd.", "TOPRAM Technology", "Silego Technology Inc.",
"Kinglife", "Ability Industries Ltd.", "Silicon Power Computer & Communications",
"Augusta Technology, Inc.", "Nantronics Semiconductors", "Hilscher Gesellschaft", "Quixant Ltd.",
"Percello Ltd.", "NextIO Inc.", "Scanimetrics Inc.", "FS-Semi Company Ltd.", "Infinera Corporation",
"SandForce Inc.", "Lexar Media", "Teradyne Inc.", "Memory Exchange Corp.", "Suzhou Smartek Electronics",
"Avantium Corporation", "ATP Electronics Inc.", "Valens Semiconductor Ltd", "Agate Logic, Inc.",
"Netronome", "Zenverge, Inc.", "N-trig Ltd", "SanMax Technologies Inc.", "Contour Semiconductor Inc.",
"TwinMOS", "Silicon Systems, Inc.", "V-Color Technology Inc.", "Certicom Corporation", "JSC ICC Milandr",
"PhotoFast Global Inc.", "InnoDisk Corporation", "Muscle Power", "Energy Micro", "Innofidei",
"CopperGate Communications", "Holtek Semiconductor Inc.", "Myson Century, Inc.", "FIDELIX",
"Red Digital Cinema", "Densbits Technology", "Zempro", "MoSys", "Provigent", "Triad Semiconductor, Inc."],
["Siklu Communication Ltd.", "A Force Manufacturing Ltd.", "Strontium", "Abilis Systems", "Siglead, Inc.",
"Ubicom, Inc.", "Unifosa Corporation", "Stretch, Inc.", "Lantiq Deutschland GmbH", "Visipro",
"EKMemory", "Microelectronics Institute ZTE", "Cognovo Ltd.", "Carry Technology Co. Ltd.", "Nokia",
"King Tiger Technology", "Sierra Wireless", "HT Micron", "Albatron Technology Co. Ltd.",
"Leica Geosystems AG", "BroadLight", "AEXEA", "ClariPhy Communications, Inc.", "Green Plug",
"Design Art Networks", "Mach Xtreme Technology Ltd.", "ATO Solutions Co. Ltd.", "Ramsta",
"Greenliant Systems, Ltd.", "Teikon", "Antec Hadron", "NavCom Technology, Inc.",
"Shanghai Fudan Microelectronics", "Calxeda, Inc.", "JSC EDC Electronics", "Kandit Technology Co. Ltd.",
"Ramos Technology", "Goldenmars Technology", "XeL Technology Inc.", "Newzone Corporation",
"ShenZhen MercyPower Tech", "Nanjing Yihuo Technology", "Nethra Imaging Inc.", "SiTel Semiconductor BV",
"SolidGear Corporation", "Topower Computer Ind Co Ltd.", "Wilocity", "Profichip GmbH",
"Gerad Technologies", "Ritek Corporation", "Gomos Technology Limited", "Memoright Corporation",
"D-Broad, Inc.", "HiSilicon Technologies", "Syndiant Inc.", "Enverv Inc.", "Cognex",
"Xinnova Technology Inc.", "Ultron AG", "Concord Idea Corporation", "AIM Corporation",
"Lifetime Memory Products", "Ramsway", "Recore Systems BV", "Haotian Jinshibo Science Tech",
"Being Advanced Memory", "Adesto Technologies", "Giantec Semiconductor, Inc.", "HMD Electronics AG",
"Gloway International (HK)", "Kingcore", "Anucell Technology Holding",
"Accord Software & Systems Pvt. Ltd.", "Active-Semi Inc.", "Denso Corporation", "TLSI Inc.",
"Shenzhen Daling Electronic Co. Ltd.", "Mustang", "Orca Systems", "Passif Semiconductor",
"GigaDevice Semiconductor (Beijing) Inc.", "Memphis Electronic", "Beckhoff Automation GmbH",
"Harmony Semiconductor Corp (former ProPlus Design Solutions)", "Air Computers SRL", "TMT Memory",
"Eorex Corporation", "Xingtera", "Netsol", "Bestdon Technology Co. Ltd.", "Baysand Inc.",
"Uroad Technology Co. Ltd. (former Triple Grow Industrial Ltd.)", "Wilk Elektronik S.A.",
"AAI", "Harman", "Berg Microelectronics Inc.", "ASSIA, Inc.", "Visiontek Products LLC",
"OCMEMORY", "Welink Solution Inc.", "Shark Gaming", "Avalanche Technology",
"R&D Center ELVEES OJSC", "KingboMars Technology Co. Ltd.",
"High Bridge Solutions Industria Eletronica", "Transcend Technology Co. Ltd.",
"Everspin Technologies", "Hon-Hai Precision", "Smart Storage Systems", "Toumaz Group",
"Zentel Electronics Corporation", "Panram International Corporation",
"Silicon Space Technology"]
);
$use_sysfs = -d '/sys/bus';
@ -291,9 +343,11 @@ sub manufacturer_ddr3($$)
{
my ($count, $code) = @_;
return "Invalid" if parity($count) != 1;
return "Invalid" if parity($code) != 1;
return (($code & 0x7F) - 1 > $vendors[$count & 0x7F]) ? "Unknown" :
$vendors[$count & 0x7F][($code & 0x7F) - 1];
return "Invalid" if parity($code) != 1
or ($code & 0x7F) == 0;
return "Unknown" if ($count & 0x7F) >= @vendors
or ($code & 0x7F) - 1 >= @{$vendors[$count & 0x7F]};
return $vendors[$count & 0x7F][($code & 0x7F) - 1];
}
sub manufacturer(@)
@ -356,6 +410,7 @@ sub html_encode($)
my $text = shift;
$text =~ s/</\&lt;/sg;
$text =~ s/>/\&gt;/sg;
$text =~ s/ degrees C/\&deg;C/sg;
$text =~ s/\n/<br>\n/sg;
return $text;
}
@ -550,7 +605,9 @@ sub decode_sdr_sdram($)
my $temp;
# SPD revision
printl("SPD Revision", $bytes->[62]);
# Starting with SPD revision 1.2, this byte is encoded in BCD
printl("SPD Revision", $bytes->[62] < 0x12 ? $bytes->[62] :
($bytes->[62] >> 4) . "." . ($bytes->[62] & 0xf));
#size computation
@ -582,7 +639,7 @@ sub decode_sdr_sdram($)
my $ctime = ($bytes->[9] >> 4) + ($bytes->[9] & 0xf) * 0.1;
$trcd = $bytes->[29];
$trp = $bytes->[27];;
$trp = $bytes->[27];
$tras = $bytes->[30];
printl("tCL-tRCD-tRP-tRAS",
@ -679,7 +736,6 @@ sub decode_sdr_sdram($)
else {
$temp += 15 if $temp < 4;
$temp += ($bytes->[23] & 0xf) * 0.1;
$temp .= " ns";
}
$cycle_time .= "\n$temp ns at CAS ".$cas[$#cas-1];
@ -688,7 +744,6 @@ sub decode_sdr_sdram($)
else {
$temp += 15 if $temp < 4;
$temp += ($bytes->[24] & 0xf) * 0.1;
$temp .= " ns";
}
$access_time .= "\n$temp ns at CAS ".$cas[$#cas-1];
}
@ -698,7 +753,6 @@ sub decode_sdr_sdram($)
if ($temp == 0) { $temp = "Undefined!"; }
else {
$temp += ($bytes->[25] & 0x3) * 0.25;
$temp .= " ns";
}
$cycle_time .= "\n$temp ns at CAS ".$cas[$#cas-2];
@ -706,7 +760,6 @@ sub decode_sdr_sdram($)
if ($temp == 0) { $temp = "Undefined!"; }
else {
$temp += ($bytes->[26] & 0x3) * 0.25;
$temp .= " ns";
}
$access_time .= "\n$temp ns at CAS ".$cas[$#cas-2];
}
@ -803,7 +856,7 @@ sub decode_ddr_sdram($)
$pcclk += 100 if ($pcclk % 100) >= 50; # Round properly
$pcclk = $pcclk - ($pcclk % 100);
$ddrclk = int ($ddrclk);
printl("Maximum module speed", "${ddrclk}MHz (PC${pcclk})");
printl("Maximum module speed", "$ddrclk MHz (PC${pcclk})");
#size computation
my $k = 0;
@ -992,7 +1045,7 @@ sub decode_ddr2_sdram($)
# Round down to comply with Jedec
$pcclk = $pcclk - ($pcclk % 100);
$ddrclk = int ($ddrclk);
printl("Maximum module speed", "${ddrclk}MHz (PC2-${pcclk})");
printl("Maximum module speed", "$ddrclk MHz (PC2-${pcclk})");
#size computation
my $k = 0;
@ -1127,11 +1180,14 @@ sub decode_ddr3_sdram($)
my $ctime;
my @module_types = ("Undefined", "RDIMM", "UDIMM", "SO-DIMM",
"Micro-DIMM", "Mini-RDIMM", "Mini-UDIMM");
"Micro-DIMM", "Mini-RDIMM", "Mini-UDIMM",
"Mini-CDIMM", "72b-SO-UDIMM", "72b-SO-RDIMM",
"72b-SO-CDIMM", "LRDIMM", "16b-SO-DIMM",
"32b-SO-DIMM");
printl("Module Type", ($bytes->[3] <= $#module_types) ?
$module_types[$bytes->[3]] :
sprint("Reserved (0x%.2X)", $bytes->[3]));
sprintf("Reserved (0x%.2X)", $bytes->[3]));
# speed
prints("Memory Characteristics");
@ -1149,8 +1205,10 @@ sub decode_ddr3_sdram($)
my $ddrclk = 2 * (1000 / $ctime);
my $tbits = 1 << (($bytes->[8] & 7) + 3);
my $pcclk = int ($ddrclk * $tbits / 8);
# Round down to comply with Jedec
$pcclk = $pcclk - ($pcclk % 100);
$ddrclk = int ($ddrclk);
printl("Maximum module speed", "${ddrclk}MHz (PC3-${pcclk})");
printl("Maximum module speed", "$ddrclk MHz (PC3-${pcclk})");
# Size computation
@ -1177,10 +1235,10 @@ sub decode_ddr3_sdram($)
my $trp;
my $tras;
$taa = int($bytes->[16] / $bytes->[12]);
$trcd = int($bytes->[18] / $bytes->[12]);
$trp = int($bytes->[20] / $bytes->[12]);
$tras = int((($bytes->[21] >> 4) * 256 + $bytes->[22]) / $bytes->[12]);
$taa = ceil($bytes->[16] / $bytes->[12]);
$trcd = ceil($bytes->[18] / $bytes->[12]);
$trp = ceil($bytes->[20] / $bytes->[12]);
$tras = ceil(((($bytes->[21] & 0x0f) << 8) + $bytes->[22]) / $bytes->[12]);
printl("tCL-tRCD-tRP-tRAS", join("-", $taa, $trcd, $trp, $tras));
@ -1231,10 +1289,11 @@ sub decode_ddr3_sdram($)
printl("RZQ/6 supported?", ($bytes->[30] & 1) ? "Yes" : "No");
printl("RZQ/7 supported?", ($bytes->[30] & 2) ? "Yes" : "No");
printl("DLL-Off Mode supported?", ($bytes->[30] & 128) ? "Yes" : "No");
printl("Operating temperature range", sprintf "0-%dC",
printl("Operating temperature range", sprintf "0-%d degrees C",
($bytes->[31] & 1) ? 95 : 85);
printl("Refresh Rate in extended temp range",
($bytes->[31] & 2) ? "2X" : "1X");
printl_cond($bytes->[31] & 1,
"Refresh Rate in extended temp range",
($bytes->[31] & 2) ? "1X" : "2X");
printl("Auto Self-Refresh?", ($bytes->[31] & 4) ? "Yes" : "No");
printl("On-Die Thermal Sensor readout?",
($bytes->[31] & 8) ? "Yes" : "No");
@ -1457,9 +1516,9 @@ sub decode_intel_spec_freq($)
prints("Intel Specification");
if ($bytes->[126] == 0x66) { $temp = "66MHz"; }
elsif ($bytes->[126] == 100) { $temp = "100MHz or 133MHz"; }
elsif ($bytes->[126] == 133) { $temp = "133MHz"; }
if ($bytes->[126] == 0x66) { $temp = "66 MHz"; }
elsif ($bytes->[126] == 100) { $temp = "100 MHz or 133 MHz"; }
elsif ($bytes->[126] == 133) { $temp = "133 MHz"; }
else { $temp = "Undefined!"; }
printl("Frequency", $temp);
@ -1475,7 +1534,7 @@ sub decode_intel_spec_freq($)
if ($bytes->[127] & 128) { $temp .= "CLK 0 Connected\n"; }
if (($bytes->[127] & 192) == 192) { $temp .= "Double-sided DIMM\n"; }
elsif (($bytes->[127] & 192) != 0) { $temp .= "Single-sided DIMM\n"; }
printl("Details for 100MHz Support", $temp);
printl("Details for 100 MHz Support", $temp);
}
# Read various hex dump style formats: hexdump, hexdump -C, i2cdump, eeprog
@ -1739,7 +1798,7 @@ sub sysfs_device_attribute
sub get_dimm_list
{
my (@dirs, $dir, $file, @files);
my (@dirs, $dir, $opened, $file, @files);
if ($use_sysfs) {
@dirs = ('/sys/bus/i2c/drivers/eeprom', '/sys/bus/i2c/drivers/at24');
@ -1749,6 +1808,7 @@ sub get_dimm_list
foreach $dir (@dirs) {
next unless opendir(local *DIR, $dir);
$opened++;
while (defined($file = readdir(DIR))) {
if ($use_sysfs) {
# We look for I2C devices like 0-0050 or 2-0051
@ -1769,12 +1829,12 @@ sub get_dimm_list
close(DIR);
}
if (@files) {
return sort { $a->{file} cmp $b->{file} } @files;
} elsif (! -d '/sys/module/eeprom') {
print "No EEPROM found, are you sure the eeprom module is loaded?\n";
if (!$opened) {
print STDERR "No EEPROM found, try loading the eeprom or at24 module\n";
exit;
}
return sort { $a->{file} cmp $b->{file} } @files;
}
# @dimm is a list of hashes. There's one hash for each EEPROM we found.

67
eeprom/decode-dimms.1

@ -0,0 +1,67 @@
.\"
.\" decode-dimms.1 - manpage for the i2c-tools/decode-dimms utility
.\" Copyright (C) 2013 Jaromir Capik
.\"
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License along
.\" with this program; if not, write to the Free Software Foundation, Inc.,
.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.TH decode-dimms 1 "Oct 2013" "i2c-tools" "User Commands"
.SH NAME
decode-dimms \- decode the information found in memory module SPD EEPROMs
.SH SYNOPSIS
.B decode-dimms
[-c] [-f [-b]] [-x|-X file [files..]]
.br
.B decode-dimms
-h
.SH DESCRIPTION
The purpose of the
.B decode-dimms
tool is to decode the information found in memory module SPD EEPROMs.
The SPD data is read either from the running system or dump files.
In the former case, the tool requires either the eeprom kernel module
or the at24 kernel module to be loaded.
.SH PARAMETERS
.TP
.B \-f, --format
Print nice html output
.TP
.B \-b, --bodyonly
Don't print html header (useful for postprocessing the output)
.TP
.B \--side-by-side
Display all DIMMs side-by-side if possible
.TP
.B \--merge-cells
Merge neighbour cells with identical values (side-by-side output only, default)
.TP
.B \--no-merge-cells
Don't merge neighbour cells with identical values (side-by-side output only)
.TP
.B \-c, --checksum
Decode completely even if checksum fails
.TP
.B \-x
Read data from hexdump files
.TP
.B \-X
Same as -x except treat multibyte hex data as little endian
.TP
.B \-h, --help
Display the usage summary
.SH SEE ALSO
.BR decode-vaio (1)
.SH AUTHORS
Philip Edelbrock, Christian Zuckschwerdt, Burkart Lingner, Jean Delvare

12
eeprom/decode-edid

@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2003-2006 Jean Delvare <khali@linux-fr.org>
# Copyright (C) 2003-2008 Jean Delvare <jdelvare@suse.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -17,16 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.
#
# Version 0.1 2003-07-17 Jean Delvare <khali@linux-fr.org>
# Version 0.2 2003-07-22 Jean Delvare <khali@linux-fr.org>
# Use print instead of syswrite.
# Version 0.3 2003-08-24 Jean Delvare <khali@linux-fr.org>
# Fix data block length (128 bytes instead of 256).
# Version 1.0 2004-02-08 Jean Delvare <khali@linux-fr.org>
# Added support for Linux 2.5/2.6 (i.e. sysfs).
# Version 1.1 2006-09-01 Jean Delvare <khali@linux-fr.org>
# Append /usr/sbin or /usr/local/sbin to $PATH if needed.
#
# EEPROM data decoding for EDID. EDID (Extended Display Identification
# Data) is a VESA standard which allows storing (on manufacturer's side)
# and retrieving (on user's side) of configuration information about

4
eeprom/decode-vaio

@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2002-2008 Jean Delvare <khali@linux-fr.org>
# Copyright (C) 2002-2008 Jean Delvare <jdelvare@suse.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -25,7 +25,7 @@
# Please note that this is a guess-only work. Sony support refused to help
# me, so if someone can provide information, please contact me.
# My knowledge is summarized on this page:
# http://khali.linux-fr.org/vaio/eeprom.html
# http://jdelvare.nerim.net/articles/vaio/eeprom.html
#
# It seems that if present, the EEPROM is always at 0x57.
#

35
eeprom/decode-vaio.1

@ -0,0 +1,35 @@
.\"
.\" decode-vaio.1 - manpage for the i2c-tools/decode-vaio utility
.\" Copyright (C) 2013 Jaromir Capik
.\"
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License along
.\" with this program; if not, write to the Free Software Foundation, Inc.,
.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.TH decode-vaio 1 "Oct 2013" "i2c-tools" "User Commands"
.SH NAME
decode-vaio \- decode the information found in the Sony Vaio laptop
identification EEPROMs
.SH SYNOPSIS
.B decode-vaio
.SH DESCRIPTION
The purpose of the
.B decode-vaio
tool is to decode the information found in the Sony Vaio laptop
identification EEPROMs.
The tool requires the eeprom kernel module to be loaded.
.SH SEE ALSO
.BR decode-dimms (1)
.SH AUTHOR
Jean Delvare

2
eepromer/.gitignore

@ -0,0 +1,2 @@
/eeprom
/eepromer

17
eepromer/24cXX.c

@ -1,8 +1,6 @@
/***************************************************************************
copyright : (C) by 2002-2003 Stefano Barbato
email : stefano@codesink.org
$Id$
***************************************************************************/
/***************************************************************************
@ -18,16 +16,21 @@
#include <unistd.h>
#include <stdlib.h>
#include <linux/fs.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <assert.h>
#include <string.h>
#include <i2c/smbus.h>
#include "24cXX.h"
/*
* EEPROMs need some time to process writes
* Ideally this value should either be settable with a command line parameter,
* or "guessed" at runtime using a retry loop.
*/
#define WRITE_DELAY_US 5000
static int i2c_write_1b(struct eeprom *e, __u8 buf)
{
int r;
@ -35,7 +38,7 @@ static int i2c_write_1b(struct eeprom *e, __u8 buf)
r = i2c_smbus_write_byte(e->fd, buf);
if(r < 0)
fprintf(stderr, "Error i2c_write_1b: %s\n", strerror(errno));
usleep(10);
usleep(WRITE_DELAY_US);
return r;
}
@ -46,7 +49,7 @@ static int i2c_write_2b(struct eeprom *e, __u8 buf[2])
r = i2c_smbus_write_byte_data(e->fd, buf[0], buf[1]);
if(r < 0)
fprintf(stderr, "Error i2c_write_2b: %s\n", strerror(errno));
usleep(10);
usleep(WRITE_DELAY_US);
return r;
}
@ -58,7 +61,7 @@ static int i2c_write_3b(struct eeprom *e, __u8 buf[3])
r = i2c_smbus_write_word_data(e->fd, buf[0], buf[2] << 8 | buf[1]);
if(r < 0)
fprintf(stderr, "Error i2c_write_3b: %s\n", strerror(errno));
usleep(10);
usleep(WRITE_DELAY_US);
return r;
}

2
eepromer/24cXX.h

@ -1,8 +1,6 @@
/***************************************************************************
copyright : (C) by 2002-2003 Stefano Barbato
email : stefano@codesink.org
$Id$
***************************************************************************/
/***************************************************************************

103
eepromer/eeprog.8

@ -0,0 +1,103 @@
.\"
.\" eeprog.8 - manpage for the i2c-tools/eeprog utility
.\" Copyright (C) 2013 Jaromir Capik
.\"
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License along
.\" with this program; if not, write to the Free Software Foundation, Inc.,
.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.TH eeprog "8" "Jul 2013" "i2c-tools" "System Administration"
.SH NAME
eeprog \- reads and writes 24Cxx EEPROMs connected to I2C serial bus
.SH SYNOPSIS
.B eeprog
[-fqxdh] [-16|-8] [-r addr[:count]|-w addr] <device> <i2c-addr>
.SH DESCRIPTION
.B eeprog
uses the SMBus protocol used by most of the recent chipsets.
.SH NOTE
Don't forget to load your i2c chipset and the i2c-dev drivers.
.P
The following environment variables could be set instead of the command line arguments:
.P
EEPROG_DEV device
.br
EEPROG_I2C_ADDR i2c-addr
.SH PARAMETERS
.I Address modes
.TP
.B \-8
Use 8bit address mode for 24c0x...24C16 [default]
.TP
.B \-16
Use 16bit address mode for 24c32...24C256
.TP
.I Actions
.TP
.B \-r addr[:count]
Read
.B count
(1 if omitted) bytes from
.B addr
and print them to the standard output
.TP
.B \-w addr
Write input (stdin) at address
.B addr
of the EEPROM
.TP
.B \-h
Print this help
.TP
.I Options
.TP
.B \-x
Set hex output mode
.TP
.B \-d
Dummy mode, display what *would* have been done
.TP
.B \-f
Disable warnings and don't ask confirmation
.TP
.B \-q
Quiet mode
.TP
.I Bus
.TP
.B device
Device file representing the I2C bus (eg. /dev/i2c-0)
.TP
.B i2c-addr
I2C bus address of the EEPROM (eg. 0x3A)
.SH EXAMPLES
Read 64 bytes from the EEPROM at address 0x54 on bus 0 starting at address 123 (decimal)
.P
.B eeprog
/dev/i2c-0 0x54 -r 123:64
.P
Print the hex codes of the first 32 bytes read from bus 1 at address 0x22
.P
.B eeprog
/dev/i2c-1 0x51 -x -r 0x22:0x20
.P
Write the current timestamp at address 0x200 of the EEPROM on bus 0 at address 0x33
.P
date |
.B eeprog
/dev/i2c-0 0x33 -w 0x200
.SH SEE ALSO
.BR eeprom (8),
.BR eepromer (8)
.SH AUTHOR
Stefano Barbato

2
eepromer/eeprog.c

@ -1,8 +1,6 @@
/***************************************************************************
copyright : (C) by 2002-2003 Stefano Barbato
email : stefano@codesink.org
$Id$
***************************************************************************/
/***************************************************************************

64
eepromer/eeprom.8

@ -0,0 +1,64 @@
.\"
.\" eeprom.8 - manpage for the i2c-tools/eeprom utility
.\" Copyright (C) 2013 Jaromir Capik
.\"
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License along
.\" with this program; if not, write to the Free Software Foundation, Inc.,
.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.TH eeprom "8" "Jul 2013" "i2c-tools" "System Administration"
.SH NAME
eeprom \- reads and writes 24Cxx EEPROMs connected to I2C serial bus
.SH SYNOPSIS
.B eeprom
[-d dev] [-a addr] [-p pgs] [-w] [-y] [-f file]
.SH DESCRIPTION
.B eeprom
can be used for reading from / writing to I2C EEPROMs like the popular
24C16, 24C08, 24C04, etc.
In contrast to
.B eeprommer
which supports 24C256-type EEPROMs,
this tool works with 1-byte addresses!
.SH NOTES
Don't forget to load your i2c chipset and the i2c-dev drivers.
.P
Pages/addresses:
EEPROMs with more than 256 bytes appear as if they
were several EEPROMs with consecutive addresses on the bus
so we might as well address several separate EEPROMs with
increasing addresses
.SH PARAMETERS
.TP
.B dev
device (default /dev/i2c-0)
.TP
.B addr
base address of EEPROM (default 0xA0)
.TP
.B pgs
number of pages to read (default 8)
.TP
.B \-w
write to EEPROM (default is reading!)
.TP
.B \-y
suppress warning when writing (default is to warn!)
.TP
.B \-f file
copy EEPROM contents to/from file (default for read is test only; for write is all zeros)
.SH SEE ALSO
.BR eeprog (8),
.BR eepromer (8)
.SH AUTHOR
Christian Vogel

1
eepromer/eeprom.c

@ -10,7 +10,6 @@ Of course the program is provided without warranty of any kind.
#include <fcntl.h>
#include <string.h>
#include <time.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
/*

61
eepromer/eepromer.8

@ -0,0 +1,61 @@
.\"
.\" eeprom.8 - manpage for the i2c-tools/eeprom utility
.\" Copyright (C) 2013 Jaromir Capik
.\"
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License along
.\" with this program; if not, write to the Free Software Foundation, Inc.,
.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.TH eepromer "8" "Jul 2013" "i2c-tools" "System Administration"
.SH NAME
eepromer \- reads and writes 24Cxx EEPROMs connected to I2C serial bus
.SH SYNOPSIS
.B eepromer
[-r|-w|-e|-p] -f <device> <i2c-addr>
.SH DESCRIPTION
The EEPROM must be a large EEPROM which uses a 2-byte address
field (24C32 or larger). It will NOT WORK on small EEPROMs
(24C01 - 24C16) such as those used on SDRAM DIMMs.
.SH NOTES
Don't forget to load your i2c chipset and the i2c-dev drivers.
.P
Tested only on 24C256.
.P
.SH PARAMETERS
.TP
.I Actions
.TP
.B \-r
Read
.TP
.B \-w
Write
.TP
.B \-e
Erase
.TP
.B \-p
Print header
.TP
.I Bus
.TP
.B \-f device
Device file representing the I2C bus (eg. /dev/i2c-0)
.TP
.B i2c-addr
I2C bus address of the EEPROM (eg. 0x3A)
.SH SEE ALSO
.BR eeprog (8),
.BR eeprom (8)
.SH AUTHOR
Daniel Smolik

1
eepromer/eepromer.c

@ -6,7 +6,6 @@
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>

6
include/Module.mk

@ -1,6 +1,6 @@
# Linux I2C header files
#
# Copyright (C) 2007, 2012 Jean Delvare <khali@linux-fr.org>
# Copyright (C) 2007 Jean Delvare <jdelvare@suse.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -9,14 +9,14 @@
INCLUDE_DIR := include
INCLUDE_TARGETS := i2c/smbus.h
INCLUDE_TARGETS := linux/i2c-dev.h
#
# Commands
#
install-include: $(addprefix $(INCLUDE_DIR)/,$(INCLUDE_TARGETS))
$(INSTALL_DIR) $(DESTDIR)$(incdir)/i2c
$(INSTALL_DIR) $(DESTDIR)$(incdir)/linux
for file in $(INCLUDE_TARGETS) ; do \
$(INSTALL_DATA) $(INCLUDE_DIR)/$$file $(DESTDIR)$(incdir)/$$file ; done

258
include/linux/i2c-dev.h

@ -24,6 +24,90 @@
#define _LINUX_I2C_DEV_H
#include <linux/types.h>
#include <sys/ioctl.h>
#include <stddef.h>
/* -- i2c.h -- */
/*
* I2C Message - used for pure i2c transaction, also from /dev interface
*/
struct i2c_msg {
__u16 addr; /* slave address */
unsigned short flags;
#define I2C_M_TEN 0x10 /* we have a ten bit chip address */
#define I2C_M_RD 0x01
#define I2C_M_NOSTART 0x4000
#define I2C_M_REV_DIR_ADDR 0x2000
#define I2C_M_IGNORE_NAK 0x1000
#define I2C_M_NO_RD_ACK 0x0800
short len; /* msg length */
char *buf; /* pointer to msg data */
};
/* To determine what functionality is present */
#define I2C_FUNC_I2C 0x00000001
#define I2C_FUNC_10BIT_ADDR 0x00000002
#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
#define I2C_FUNC_SMBUS_PEC 0x00000008
#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
#define I2C_FUNC_SMBUS_QUICK 0x00010000
#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */
#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
I2C_FUNC_SMBUS_WRITE_BYTE)
#define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \
I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
#define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \
I2C_FUNC_SMBUS_WRITE_WORD_DATA)
#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
/* Old name, for compatibility */
#define I2C_FUNC_SMBUS_HWPEC_CALC I2C_FUNC_SMBUS_PEC
/*
* Data for SMBus Messages
*/
#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
#define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */
union i2c_smbus_data {
__u8 byte;
__u16 word;
__u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */
/* and one more for PEC */
};
/* smbus_access read or write markers */
#define I2C_SMBUS_READ 1
#define I2C_SMBUS_WRITE 0
/* SMBus transaction types (size parameter in the above functions)
Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
#define I2C_SMBUS_QUICK 0
#define I2C_SMBUS_BYTE 1
#define I2C_SMBUS_BYTE_DATA 2
#define I2C_SMBUS_WORD_DATA 3
#define I2C_SMBUS_PROC_CALL 4
#define I2C_SMBUS_BLOCK_DATA 5
#define I2C_SMBUS_I2C_BLOCK_BROKEN 6
#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */
#define I2C_SMBUS_I2C_BLOCK_DATA 8
/* /dev/i2c-X ioctl commands. The ioctl's parameter is always an
@ -69,4 +153,178 @@ struct i2c_rdwr_ioctl_data {
#define I2C_RDRW_IOCTL_MAX_MSGS 42
static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,
int size, union i2c_smbus_data *data)
{
struct i2c_smbus_ioctl_data args;
args.read_write = read_write;
args.command = command;
args.size = size;
args.data = data;
return ioctl(file,I2C_SMBUS,&args);
}
static inline __s32 i2c_smbus_write_quick(int file, __u8 value)
{
return i2c_smbus_access(file,value,0,I2C_SMBUS_QUICK,NULL);
}
static inline __s32 i2c_smbus_read_byte(int file)
{
union i2c_smbus_data data;
if (i2c_smbus_access(file,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE,&data))
return -1;
else
return 0x0FF & data.byte;
}
static inline __s32 i2c_smbus_write_byte(int file, __u8 value)
{
return i2c_smbus_access(file,I2C_SMBUS_WRITE,value,
I2C_SMBUS_BYTE,NULL);
}
static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command)
{
union i2c_smbus_data data;
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
I2C_SMBUS_BYTE_DATA,&data))
return -1;
else
return 0x0FF & data.byte;
}
static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command,
__u8 value)
{
union i2c_smbus_data data;
data.byte = value;
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
I2C_SMBUS_BYTE_DATA, &data);
}
static inline __s32 i2c_smbus_read_word_data(int file, __u8 command)
{
union i2c_smbus_data data;
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
I2C_SMBUS_WORD_DATA,&data))
return -1;
else
return 0x0FFFF & data.word;
}
static inline __s32 i2c_smbus_write_word_data(int file, __u8 command,
__u16 value)
{
union i2c_smbus_data data;
data.word = value;
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
I2C_SMBUS_WORD_DATA, &data);
}
static inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value)
{
union i2c_smbus_data data;
data.word = value;
if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
I2C_SMBUS_PROC_CALL,&data))
return -1;
else
return 0x0FFFF & data.word;
}
/* Returns the number of read bytes */
static inline __s32 i2c_smbus_read_block_data(int file, __u8 command,
__u8 *values)
{
union i2c_smbus_data data;
int i;
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
I2C_SMBUS_BLOCK_DATA,&data))
return -1;
else {
for (i = 1; i <= data.block[0]; i++)
values[i-1] = data.block[i];
return data.block[0];
}
}
static inline __s32 i2c_smbus_write_block_data(int file, __u8 command,
__u8 length, const __u8 *values)
{
union i2c_smbus_data data;
int i;
if (length > 32)
length = 32;
for (i = 1; i <= length; i++)
data.block[i] = values[i-1];
data.block[0] = length;
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
I2C_SMBUS_BLOCK_DATA, &data);
}
/* Returns the number of read bytes */
/* Until kernel 2.6.22, the length is hardcoded to 32 bytes. If you
ask for less than 32 bytes, your code will only work with kernels
2.6.23 and later. */
static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command,
__u8 length, __u8 *values)
{
union i2c_smbus_data data;
int i;
if (length > 32)
length = 32;
data.block[0] = length;
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
length == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN :
I2C_SMBUS_I2C_BLOCK_DATA,&data))
return -1;
else {
for (i = 1; i <= data.block[0]; i++)
values[i-1] = data.block[i];
return data.block[0];
}
}
static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command,
__u8 length,
const __u8 *values)
{
union i2c_smbus_data data;
int i;
if (length > 32)
length = 32;
for (i = 1; i <= length; i++)
data.block[i] = values[i-1];
data.block[0] = length;
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
I2C_SMBUS_I2C_BLOCK_BROKEN, &data);
}
/* Returns the number of read bytes */
static inline __s32 i2c_smbus_block_process_call(int file, __u8 command,
__u8 length, __u8 *values)
{
union i2c_smbus_data data;
int i;
if (length > 32)
length = 32;
for (i = 1; i <= length; i++)
data.block[i] = values[i-1];
data.block[0] = length;
if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
I2C_SMBUS_BLOCK_PROC_CALL,&data))
return -1;
else {
for (i = 1; i <= data.block[0]; i++)
values[i-1] = data.block[i];
return data.block[0];
}
}
#endif /* _LINUX_I2C_DEV_H */

2
py-smbus/Module.mk

@ -14,7 +14,7 @@ DISTUTILS := \
cd $(PY_SMBUS_DIR) && \
CPPFLAGS="$(CPPFLAGS) -I../include" $(PYTHON) setup.py
all-python: $(INCLUDE_DIR)/i2c/smbus.h
all-python: $(INCLUDE_DIR)/linux/i2c-dev.h
$(DISTUTILS) build
clean-python:

2
py-smbus/setup.py

@ -10,5 +10,5 @@ setup( name="smbus",
maintainer="Mark M. Hoffman",
maintainer_email="linux-i2c@vger.kernel.org",
license="GPLv2",
url="http://lm-sensors.org/",
url="https://i2c.wiki.kernel.org/index.php/I2C_Tools",
ext_modules=[Extension("smbus", ["smbusmodule.c"])])

54
py-smbus/smbusmodule.c

@ -13,7 +13,8 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include <Python.h>
@ -22,9 +23,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <i2c/smbus.h>
/*
** These are required to build this module against Linux older than 2.6.23.
@ -94,7 +93,11 @@ SMBus_dealloc(SMBus *self)
PyObject *ref = SMBus_close(self);
Py_XDECREF(ref);
#if PY_MAJOR_VERSION >= 3
Py_TYPE(self)->tp_free((PyObject *)self);
#else
self->ob_type->tp_free((PyObject *)self);
#endif
}
#define MAXPATH 16
@ -434,11 +437,19 @@ SMBus_list_to_data(PyObject *list, union i2c_smbus_data *data)
for (ii = 0; ii < len; ii++) {
PyObject *val = PyList_GET_ITEM(list, ii);
#if PY_MAJOR_VERSION >= 3
if (!PyLong_Check(val)) {
PyErr_SetString(PyExc_TypeError, msg);
return 0; /* fail */
}
data->block[ii+1] = (__u8)PyLong_AS_LONG(val);
#else
if (!PyInt_Check(val)) {
PyErr_SetString(PyExc_TypeError, msg);
return 0; /* fail */
}
data->block[ii+1] = (__u8)PyInt_AS_LONG(val);
#endif
}
return 1; /* success */
@ -637,9 +648,14 @@ static PyGetSetDef SMBus_getset[] = {
};
static PyTypeObject SMBus_type = {
#if PY_MAJOR_VERSION >= 3
PyVarObject_HEAD_INIT(NULL, 0)
"SMBus", /* tp_name */
#else
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"SMBus", /* tp_name */
"smbus.SMBus", /* tp_name */
#endif
sizeof(SMBus), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)SMBus_dealloc, /* tp_dealloc */
@ -678,24 +694,50 @@ static PyTypeObject SMBus_type = {
SMBus_new, /* tp_new */
};
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef SMBusModule = {
PyModuleDef_HEAD_INIT,
"SMBus", /* m_name */
SMBus_module_doc, /* m_doc */
-1, /* m_size */
NULL, /* m_methods */
NULL, /* m_reload */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL, /* m_free */
};
#define INIT_RETURN(m) return m
#define INIT_FNAME PyInit_smbus
#else
static PyMethodDef SMBus_module_methods[] = {
{NULL}
};
#define INIT_RETURN(m) return
#define INIT_FNAME initsmbus
#endif
#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
#define PyMODINIT_FUNC void
#endif
PyMODINIT_FUNC
initsmbus(void)
INIT_FNAME(void)
{
PyObject* m;
if (PyType_Ready(&SMBus_type) < 0)
return;
INIT_RETURN(NULL);
#if PY_MAJOR_VERSION >= 3
m = PyModule_Create(&SMBusModule);
#else
m = Py_InitModule3("smbus", SMBus_module_methods, SMBus_module_doc);
#endif
if (m == NULL)
INIT_RETURN(NULL);
Py_INCREF(&SMBus_type);
PyModule_AddObject(m, "SMBus", (PyObject *)&SMBus_type);
INIT_RETURN(m);
}

2
stub/Module.mk

@ -1,6 +1,6 @@
# Helper for the Linux i2c-stub bus driver
#
# Copyright (C) 2007-2008 Jean Delvare <khali@linux-fr.org>
# Copyright (C) 2007-2009 Jean Delvare <jdelvare@suse.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

2
stub/i2c-stub-from-dump

@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2007-2008 Jean Delvare <khali@linux-fr.org>
# Copyright (C) 2007-2012 Jean Delvare <jdelvare@suse.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

4
tools/.gitignore

@ -0,0 +1,4 @@
/i2cdump
/i2cset
/i2cget
/i2cdetect

14
tools/Module.mk

@ -1,6 +1,6 @@
# I2C tools for Linux
#
# Copyright (C) 2007, 2012 Jean Delvare <khali@linux-fr.org>
# Copyright (C) 2007 Jean Delvare <jdelvare@suse.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -10,7 +10,7 @@
TOOLS_DIR := tools
TOOLS_CFLAGS := -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \
-Wcast-align -Wwrite-strings -Wnested-externs -Winline \
-Wcast-align -Wwrite-strings -Wnested-externs \
-W -Wundef -Wmissing-prototypes -Iinclude
TOOLS_TARGETS := i2cdetect i2cdump i2cset i2cget
@ -35,19 +35,19 @@ $(TOOLS_DIR)/i2cget: $(TOOLS_DIR)/i2cget.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)
# Objects
#
$(TOOLS_DIR)/i2cdetect.o: $(TOOLS_DIR)/i2cdetect.c $(TOOLS_DIR)/i2cbusses.h version.h $(INCLUDE_DIR)/i2c/smbus.h
$(TOOLS_DIR)/i2cdetect.o: $(TOOLS_DIR)/i2cdetect.c $(TOOLS_DIR)/i2cbusses.h version.h $(INCLUDE_DIR)/linux/i2c-dev.h
$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
$(TOOLS_DIR)/i2cdump.o: $(TOOLS_DIR)/i2cdump.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h version.h $(INCLUDE_DIR)/i2c/smbus.h
$(TOOLS_DIR)/i2cdump.o: $(TOOLS_DIR)/i2cdump.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h version.h $(INCLUDE_DIR)/linux/i2c-dev.h
$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
$(TOOLS_DIR)/i2cset.o: $(TOOLS_DIR)/i2cset.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h version.h $(INCLUDE_DIR)/i2c/smbus.h
$(TOOLS_DIR)/i2cset.o: $(TOOLS_DIR)/i2cset.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h version.h $(INCLUDE_DIR)/linux/i2c-dev.h
$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
$(TOOLS_DIR)/i2cget.o: $(TOOLS_DIR)/i2cget.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h version.h $(INCLUDE_DIR)/i2c/smbus.h
$(TOOLS_DIR)/i2cget.o: $(TOOLS_DIR)/i2cget.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h version.h $(INCLUDE_DIR)/linux/i2c-dev.h
$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
$(TOOLS_DIR)/i2cbusses.o: $(TOOLS_DIR)/i2cbusses.c $(TOOLS_DIR)/i2cbusses.h
$(TOOLS_DIR)/i2cbusses.o: $(TOOLS_DIR)/i2cbusses.c $(TOOLS_DIR)/i2cbusses.h $(INCLUDE_DIR)/linux/i2c-dev.h
$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
$(TOOLS_DIR)/util.o: $(TOOLS_DIR)/util.c $(TOOLS_DIR)/util.h

55
tools/i2cbusses.c

@ -4,7 +4,7 @@
devices.
Copyright (c) 1999-2003 Frodo Looijaard <frodol@dds.nl> and
Mark D. Studebaker <mdsxyz123@yahoo.com>
Copyright (C) 2008-2012 Jean Delvare <khali@linux-fr.org>
Copyright (C) 2008-2012 Jean Delvare <jdelvare@suse.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -23,7 +23,8 @@
*/
/* For strdup and snprintf */
#define _BSD_SOURCE 1
#define _BSD_SOURCE 1 /* for glibc <= 2.19 */
#define _DEFAULT_SOURCE 1 /* for glibc >= 2.19 */
#include <sys/types.h>
#include <sys/stat.h>
@ -39,7 +40,6 @@
#include <fcntl.h>
#include <errno.h>
#include "i2cbusses.h"
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
enum adt { adt_dummy, adt_isa, adt_i2c, adt_smbus, adt_unknown };
@ -136,7 +136,7 @@ struct i2c_adap *gather_i2c_busses(void)
FILE *f;
char fstype[NAME_MAX], sysfs[NAME_MAX], n[NAME_MAX];
int foundsysfs = 0;
int count=0;
int len, count = 0;
struct i2c_adap *adapters;
adapters = calloc(BUNCH, sizeof(struct i2c_adap));
@ -219,18 +219,32 @@ struct i2c_adap *gather_i2c_busses(void)
/* this should work for kernels 2.6.5 or higher and */
/* is preferred because is unambiguous */
sprintf(n, "%s/%s/name", sysfs, de->d_name);
len = snprintf(n, NAME_MAX, "%s/%s/name", sysfs, de->d_name);
if (len >= NAME_MAX) {
fprintf(stderr, "%s: path truncated\n", n);
continue;
}
f = fopen(n, "r");
/* this seems to work for ISA */
if(f == NULL) {
sprintf(n, "%s/%s/device/name", sysfs, de->d_name);
len = snprintf(n, NAME_MAX, "%s/%s/device/name", sysfs,
de->d_name);
if (len >= NAME_MAX) {
fprintf(stderr, "%s: path truncated\n", n);
continue;
}
f = fopen(n, "r");
}
/* non-ISA is much harder */
/* and this won't find the correct bus name if a driver
has more than one bus */
if(f == NULL) {
sprintf(n, "%s/%s/device", sysfs, de->d_name);
len = snprintf(n, NAME_MAX, "%s/%s/device", sysfs,
de->d_name);
if (len >= NAME_MAX) {
fprintf(stderr, "%s: path truncated\n", n);
continue;
}
if(!(ddir = opendir(n)))
continue;
while ((dde = readdir(ddir)) != NULL) {
@ -239,8 +253,16 @@ struct i2c_adap *gather_i2c_busses(void)
if (!strcmp(dde->d_name, ".."))
continue;
if ((!strncmp(dde->d_name, "i2c-", 4))) {
sprintf(n, "%s/%s/device/%s/name",
sysfs, de->d_name, dde->d_name);
len = snprintf(n, NAME_MAX,
"%s/%s/device/%s/name",
sysfs, de->d_name,
dde->d_name);
if (len >= NAME_MAX) {
fprintf(stderr,
"%s: path truncated\n",
n);
continue;
}
if((f = fopen(n, "r")))
goto found;
}
@ -375,14 +397,21 @@ int parse_i2c_address(const char *address_arg)
int open_i2c_dev(int i2cbus, char *filename, size_t size, int quiet)
{
int file;
int file, len;
snprintf(filename, size, "/dev/i2c/%d", i2cbus);
filename[size - 1] = '\0';
len = snprintf(filename, size, "/dev/i2c/%d", i2cbus);
if (len >= (int)size) {
fprintf(stderr, "%s: path truncated\n", filename);
return -EOVERFLOW;
}
file = open(filename, O_RDWR);
if (file < 0 && (errno == ENOENT || errno == ENOTDIR)) {
sprintf(filename, "/dev/i2c-%d", i2cbus);
len = snprintf(filename, size, "/dev/i2c-%d", i2cbus);
if (len >= (int)size) {
fprintf(stderr, "%s: path truncated\n", filename);
return -EOVERFLOW;
}
file = open(filename, O_RDWR);
}

2
tools/i2cbusses.h

@ -1,7 +1,7 @@
/*
i2cbusses.h - Part of the i2c-tools package
Copyright (C) 2004-2010 Jean Delvare <khali@linux-fr.org>
Copyright (C) 2004-2010 Jean Delvare <jdelvare@suse.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

14
tools/i2cdetect.8

@ -28,6 +28,12 @@ should correspond to one of the busses listed by \fIi2cdetect -l\fR.
The optional parameters \fIfirst\fR and \fIlast\fR restrict the scanning
range (default: from 0x03 to 0x77).
.PP
As there is no standard I2C detection command, i2cdetect uses arbitrary
SMBus commands (namely SMBus quick write and SMBus receive byte) to probe
for devices. By default, the command used is the one believed to be the
safest for each address. See options \fI-q\fR and \fI-r\fR to change this
behavior.
.PP
i2cdetect can also be used to query the functionalities of an I2C bus
(see option \fB-F\fP.)
@ -57,14 +63,12 @@ scripts.
Force scanning of non-regular addresses. Not recommended.
.TP
.B "\-q"
Use SMBus "quick write" commands for probing (by default, the command
used is the one believed to be the safest for each address).
Use SMBus "quick write" command for probing.
Not recommended. This is known to corrupt the Atmel AT24RF08 EEPROM
found on many IBM Thinkpad laptops.
.TP
.B "\-r"
Use SMBus "read byte" commands for probing (by default, the command
used is the one believed to be the safest for each address).
Use SMBus "receive byte" command for probing.
Not recommended. This is known to lock SMBus on various write-only
chips (most notably clock chips at address 0x69).
.TP
@ -78,7 +82,7 @@ Display the version and exit.
Output a list of installed busses.
.SH SEE ALSO
i2cdump(8), sensors-detect(8)
i2cdump(8), i2cget(8), i2cset(8), sensors-detect(8)
.SH AUTHOR
Frodo Looijaard, Mark D. Studebaker and Jean Delvare

4
tools/i2cdetect.c

@ -2,7 +2,7 @@
i2cdetect.c - a user-space program to scan for I2C devices
Copyright (C) 1999-2004 Frodo Looijaard <frodol@dds.nl>, and
Mark D. Studebaker <mdsxyz123@yahoo.com>
Copyright (C) 2004-2012 Jean Delvare <khali@linux-fr.org>
Copyright (C) 2004-2012 Jean Delvare <jdelvare@suse.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -26,9 +26,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <i2c/smbus.h>
#include "i2cbusses.h"
#include "../version.h"

2
tools/i2cdump.8

@ -75,7 +75,7 @@ knowledge of the chip you're working with and an idea of what you are looking
for.
.SH SEE ALSO
i2cset(8), i2cdetect(8), isadump(8)
i2cdetect(8), i2cget(8), i2cset(8), isadump(8)
.SH AUTHOR
Frodo Looijaard, Mark D. Studebaker and Jean Delvare

4
tools/i2cdump.c

@ -2,7 +2,7 @@
i2cdump.c - a user-space program to dump I2C registers
Copyright (C) 2002-2003 Frodo Looijaard <frodol@dds.nl>, and
Mark D. Studebaker <mdsxyz123@yahoo.com>
Copyright (C) 2004-2012 Jean Delvare <khali@linux-fr.org>
Copyright (C) 2004-2012 Jean Delvare <jdelvare@suse.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -26,9 +26,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <i2c/smbus.h>
#include "i2cbusses.h"
#include "util.h"
#include "../version.h"

2
tools/i2cget.8

@ -59,7 +59,7 @@ certain chips. This is particularly true if setting \fImode\fR to \fBcp\fP (writ
byte with PEC). Be extremely careful using this program.
.SH SEE ALSO
i2cdump(8), i2cset(8)
i2cdetect(8), i2cdump(8), i2cset(8)
.SH AUTHOR
Jean Delvare

6
tools/i2cget.c

@ -1,11 +1,11 @@
/*
i2cget.c - A user-space program to read an I2C register.
Copyright (C) 2005-2012 Jean Delvare <khali@linux-fr.org>
Copyright (C) 2005-2012 Jean Delvare <jdelvare@suse.de>
Based on i2cset.c:
Copyright (C) 2001-2003 Frodo Looijaard <frodol@dds.nl>, and
Mark D. Studebaker <mdsxyz123@yahoo.com>
Copyright (C) 2004-2005 Jean Delvare <khali@linux-fr.org>
Copyright (C) 2004-2005 Jean Delvare
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -29,9 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <i2c/smbus.h>
#include "i2cbusses.h"
#include "util.h"
#include "../version.h"

2
tools/i2cset.8

@ -93,7 +93,7 @@ DESTROY your memory, leaving your system unbootable! Be extremely careful
using this program.
.SH SEE ALSO
i2cdump(8), isaset(8)
i2cdetect(8), i2cdump(8), i2cget(8) isaset(8)
.SH AUTHOR
Frodo Looijaard, Mark D. Studebaker and Jean Delvare

31
tools/i2cset.c

@ -2,7 +2,7 @@
i2cset.c - A user-space program to write an I2C register.
Copyright (C) 2001-2003 Frodo Looijaard <frodol@dds.nl>, and
Mark D. Studebaker <mdsxyz123@yahoo.com>
Copyright (C) 2004-2012 Jean Delvare <khali@linux-fr.org>
Copyright (C) 2004-2012 Jean Delvare <jdelvare@suse.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -26,9 +26,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <i2c/smbus.h>
#include "i2cbusses.h"
#include "util.h"
#include "../version.h"
@ -38,7 +36,7 @@ static void help(void) __attribute__ ((noreturn));
static void help(void)
{
fprintf(stderr,
"Usage: i2cset [-f] [-y] [-m MASK] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n"
"Usage: i2cset [-f] [-y] [-m MASK] [-r] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]\n"
" I2CBUS is an integer or an I2C bus name\n"
" ADDRESS is an integer (0x03 - 0x77)\n"
" MODE is one of:\n"
@ -125,11 +123,11 @@ static int confirm(const char *filename, int address, int size, int daddress,
}
fprintf(stderr, "I will write to device file %s, chip address "
"0x%02x, data address\n0x%02x, ", filename, address, daddress);
if (size == I2C_SMBUS_BYTE)
fprintf(stderr, "no data.\n");
else if (size == I2C_SMBUS_BLOCK_DATA ||
size == I2C_SMBUS_I2C_BLOCK_DATA) {
"0x%02x,\n", filename, address);
if (size != I2C_SMBUS_BYTE)
fprintf(stderr, "data address 0x%02x, ", daddress);
if (size == I2C_SMBUS_BLOCK_DATA ||
size == I2C_SMBUS_I2C_BLOCK_DATA) {
int i;
fprintf(stderr, "data");
@ -140,7 +138,7 @@ static int confirm(const char *filename, int address, int size, int daddress,
} else
fprintf(stderr, "data 0x%02x%s, mode %s.\n", value,
vmask ? " (masked)" : "",
size == I2C_SMBUS_BYTE_DATA ? "byte" : "word");
size == I2C_SMBUS_WORD_DATA ? "word" : "byte");
if (pec)
fprintf(stderr, "PEC checking enabled.\n");
@ -263,6 +261,10 @@ int main(int argc, char *argv[])
/* read values from command line */
switch (size) {
case I2C_SMBUS_BYTE:
/* short write: data address was not really data address */
value = daddress;
break;
case I2C_SMBUS_BYTE_DATA:
case I2C_SMBUS_WORD_DATA:
value = strtol(argv[flags+4], &end, 0);
@ -343,12 +345,10 @@ int main(int argc, char *argv[])
if (!yes) {
fprintf(stderr, "Old value 0x%0*x, write mask "
"0x%0*x: Will write 0x%0*x to register "
"0x%02x\n",
"0x%0*x, will write 0x%0*x\n",
size == I2C_SMBUS_WORD_DATA ? 4 : 2, oldvalue,
size == I2C_SMBUS_WORD_DATA ? 4 : 2, vmask,
size == I2C_SMBUS_WORD_DATA ? 4 : 2, value,
daddress);
size == I2C_SMBUS_WORD_DATA ? 4 : 2, value);
fprintf(stderr, "Continue? [Y/n] ");
fflush(stderr);
@ -368,7 +368,7 @@ int main(int argc, char *argv[])
switch (size) {
case I2C_SMBUS_BYTE:
res = i2c_smbus_write_byte(file, daddress);
res = i2c_smbus_write_byte(file, value);
break;
case I2C_SMBUS_WORD_DATA:
res = i2c_smbus_write_word_data(file, daddress, value);
@ -406,7 +406,6 @@ int main(int argc, char *argv[])
switch (size) {
case I2C_SMBUS_BYTE:
res = i2c_smbus_read_byte(file);
value = daddress;
break;
case I2C_SMBUS_WORD_DATA:
res = i2c_smbus_read_word_data(file, daddress);

2
tools/util.c

@ -1,6 +1,6 @@
/*
util.c - helper functions
Copyright (C) 2006 Jean Delvare <khali@linux-fr.org>
Copyright (C) 2006-2009 Jean Delvare <jdelvare@suse.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

2
tools/util.h

@ -1,6 +1,6 @@
/*
util - helper functions
Copyright (C) 2006 Jean Delvare <khali@linux-fr.org>
Copyright (C) 2006-2009 Jean Delvare <jdelvare@suse.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

2
version.h

@ -1 +1 @@
#define VERSION "3.1.0"
#define VERSION "3.1.2"
Loading…
Cancel
Save