Accepting request 539806 from Base:System
- i2cbusses-path-overflows.patch: Prevent buffer overflow of sysfs paths. - Update to version 4.0: * New library libi2c * Many fixes and improvements to decode-dimms * New manual pages and examples added to existing manual pages * New tool i2ctransfer - Removed obsolete decode-dimms-correctly-check-for-out-of-bounds-vendor-id.patch, i2c-tools-hackweek-9-dependencies.diff, i2c-tools-hackweek-9-improve-DDR3-support.diff, i2c-tools-r6048-Move-SMBus-helper-functions.patch, i2c-tools-r6053-Add-smbus-header.patch (upstream) OBS-URL: https://build.opensuse.org/request/show/539806 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/i2c-tools?expand=0&rev=33
This commit is contained in:
commit
97c7ef5124
@ -1,27 +0,0 @@
|
|||||||
From: Jean Delvare <jdelvare@suse.de>
|
|
||||||
Date: Thu, 23 Jun 2016 18:59:07 +0200
|
|
||||||
Subject: decode-dimms: Correctly check for out-of-bounds vendor ID
|
|
||||||
Upstream: yes
|
|
||||||
Git-commit: 2b4135907c1aa27edeb397e62b67386ff5d7d3d5
|
|
||||||
|
|
||||||
---
|
|
||||||
eeprom/decode-dimms | 8 +++++---
|
|
||||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
--- i2c-tools-3.1.2.orig/eeprom/decode-dimms 2017-07-06 12:55:49.998319548 +0200
|
|
||||||
+++ i2c-tools-3.1.2/eeprom/decode-dimms 2017-07-06 12:55:51.398337567 +0200
|
|
||||||
@@ -343,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(@)
|
|
@ -1,17 +0,0 @@
|
|||||||
-----BEGIN PGP SIGNATURE-----
|
|
||||||
Version: GnuPG v2
|
|
||||||
|
|
||||||
iQIVAwUAWV3d/qVSa5uzzU5qAQIbtg/+Myg6os/BwbFv4FIpkvd0rhsKAwwng4dG
|
|
||||||
bYnnKdF7WBsh+Q83PiHTxjfu15iKjS9+SHIlIxLGnIiI/+Vs0vDVBbGUI3YXd1fP
|
|
||||||
rJWiYvdvsj7zwoJo/I6oxZIbz5fugsafIt5XJd43rRUaQCSE9b1mXFu3jnABqd6z
|
|
||||||
3imfmMX+yY+8j45EABB1mD/9kHEF+hmjWBuMndsQxUUt72mfb7H26EgfqGAZKhzp
|
|
||||||
f8DYri07x+98f54XumCWfuprs3qB2//9y5VBhiAxeleGh3tAd0Yr+q684zHuDfyo
|
|
||||||
AHoegJ0FKv9SbrYu6QdVzKG4fRVGvIn/dsQKj12tNrzEntQU9Prsx+lePhBU1V4v
|
|
||||||
xowZNQEb1r6grXHKOzgzPWgAAbfihFclJT5TIu2rXQ1PIeYDplfmHir/RmMZwG72
|
|
||||||
7vhAOYMlNvLZbk0WfajOiCjT774/TRyrh2yz7lPRaaxpAnb6yItVMPcadr3jI6Zv
|
|
||||||
yN/dt/tsf1kSKKzRWxrEG5nyaiLUsPq+Ung9amJURquRU6kOca9ej2XrirHina4V
|
|
||||||
hSnnUOiYUD9qNLqFExYSVCdEVbQQ1fWYa/V/GcH6MRVwAem2qwZ+btznEsKIa0JI
|
|
||||||
1VxxKANMRGl6IA2l7DBT6KlDPKTjNhE5KJncCFWmRuTBY7HfiP4ObSRvfVQYzdQt
|
|
||||||
uiV+6BK83fw=
|
|
||||||
=DIdi
|
|
||||||
-----END PGP SIGNATURE-----
|
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:6d6079153cd49a62d4addacef4c092db1a46ba60b2807070a3fbe050262aef87
|
|
||||||
size 69240
|
|
17
i2c-tools-4.0.tar.sign
Normal file
17
i2c-tools-4.0.tar.sign
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
-----BEGIN PGP SIGNATURE-----
|
||||||
|
Version: GnuPG v2
|
||||||
|
|
||||||
|
iQIVAwUAWfbvq6VSa5uzzU5qAQKsSQ//U+7cC9Iz99FxwgwZNGK+d6syhxxq7/4m
|
||||||
|
xf/P2D+WcbT5cZXMSlvliFPGdiQfQ8q9hbB7UEkwAm/SGOreBc6xv+toTr0C0Nb0
|
||||||
|
LzpHZi1YPRn6fq8/QItLyadYpLbYfis37Tx/NpOcJOrYw0yQcP+JeB4yIWlRXnng
|
||||||
|
QN/pugZz8jrK2kXlkLFNyoJH4yo4sWVmxSqrcYyihNmPWCcQPeoXNCziYUe4BgHD
|
||||||
|
WsV4pNdEMlMDdwE92ifKcXM5I8ykCF4V4PC0zNlG9YfHwiKX8vRlQb+BFqWSz5Pt
|
||||||
|
q728OpwbJy3MpdipqLIwjxKqRqjDY09XSog8cttZcIG+f1s6afFIKyD6+spkkQMu
|
||||||
|
rwtUjP3XZxsI1aTJoYJZUZtYzMNqgGbSXEQuuWrX51881IV54P3oL+dR8UYktt/e
|
||||||
|
k9q2NYZDAak8KO0fnui3sDjxUONVbXQMdM8O1buy1iJAjLKGntWDyo/6l/pH4yNG
|
||||||
|
BYJc2nAJwEiJklWOJeyuvg5kNgbs1aclBxeqIShVrZsa+C1pAxdfaQqMLVsvM/Jr
|
||||||
|
h1W9MlJHEFzbIUzPj0I4Wokc7SfWpeaY+4noKMqrXfhKqxMZQLXH6qtIFiRc7U2i
|
||||||
|
UIj/PMOt/plS1EnlziZ3VQi32ZfRocTHIb5rkvwN9ZpJO2EOzGa5CosS7X03PyYy
|
||||||
|
fnwRF2FlfhY=
|
||||||
|
=rICC
|
||||||
|
-----END PGP SIGNATURE-----
|
3
i2c-tools-4.0.tar.xz
Normal file
3
i2c-tools-4.0.tar.xz
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:d900ca1c11c51ea20caa50b096f948008b8a7ad832311b23353e21baa7af28d6
|
||||||
|
size 79972
|
@ -1,34 +0,0 @@
|
|||||||
Subject: decode-dimms: Backport two functions
|
|
||||||
Upstream: yes, r6079 (partial), r6093 (partial), r6095 (partial)
|
|
||||||
|
|
||||||
Backport functions as_ddr() and ddr_core_timings() which are needed
|
|
||||||
by the hackweek 9 code.
|
|
||||||
---
|
|
||||||
eeprom/decode-dimms | 16 ++++++++++++++++
|
|
||||||
1 file changed, 16 insertions(+)
|
|
||||||
|
|
||||||
--- a/eeprom/decode-dimms
|
|
||||||
+++ b/eeprom/decode-dimms
|
|
||||||
@@ -826,6 +826,22 @@ sub decode_sdr_sdram($)
|
|
||||||
(($bytes->[35] >> 7) ? -$temp : $temp) . " ns");
|
|
||||||
}
|
|
||||||
|
|
||||||
+sub as_ddr($$)
|
|
||||||
+{
|
|
||||||
+ my ($gen, $ctime) = @_;
|
|
||||||
+
|
|
||||||
+ return " as DDR" . ($gen == 1 ? "" : $gen) . "-" .
|
|
||||||
+ int(2000 / $ctime);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+sub ddr_core_timings($$$$$)
|
|
||||||
+{
|
|
||||||
+ my ($cas, $ctime, $trcd, $trp, $tras) = @_;
|
|
||||||
+
|
|
||||||
+ return $cas . "-" . ceil($trcd/$ctime) . "-" . ceil($trp/$ctime) .
|
|
||||||
+ "-" . ceil($tras/$ctime);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
# Parameter: EEPROM bytes 0-127 (using 3-62)
|
|
||||||
sub decode_ddr_sdram($)
|
|
||||||
{
|
|
@ -1,365 +0,0 @@
|
|||||||
Subject: decode-dimms: Improve DDR3 support
|
|
||||||
Upstream: yes, r6132 to r6149
|
|
||||||
|
|
||||||
This is my hackweek 9 project:
|
|
||||||
https://github.com/SUSE/hackweek/wiki/DDR3-SPD-Information-Decoding
|
|
||||||
---
|
|
||||||
eeprom/decode-dimms | 271 +++++++++++++++++++++++++++++++++++++---------------
|
|
||||||
1 file changed, 195 insertions(+), 76 deletions(-)
|
|
||||||
|
|
||||||
--- a/eeprom/decode-dimms
|
|
||||||
+++ b/eeprom/decode-dimms
|
|
||||||
@@ -1186,36 +1186,137 @@ sub decode_ddr2_sdram($)
|
|
||||||
printl("PLL Relock Time", $bytes->[46] . " us") if ($bytes->[46]);
|
|
||||||
}
|
|
||||||
|
|
||||||
+# Return combined time in ns
|
|
||||||
+sub ddr3_mtb_ftb($$$$)
|
|
||||||
+{
|
|
||||||
+ my ($byte1, $byte2, $mtb, $ftb) = @_;
|
|
||||||
+
|
|
||||||
+ # byte1 is unsigned in ns, but byte2 is signed in ps
|
|
||||||
+ $byte2 -= 0x100 if $byte2 & 0x80;
|
|
||||||
+
|
|
||||||
+ return $byte1 * $mtb + $byte2 * $ftb / 1000;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+sub ddr3_reference_card($$)
|
|
||||||
+{
|
|
||||||
+ my ($rrc, $ext) = @_;
|
|
||||||
+ my $alphabet = "ABCDEFGHJKLMNPRTUVWY";
|
|
||||||
+ my $ref = $rrc & 0x1f;
|
|
||||||
+ my $revision = $ext >> 5;
|
|
||||||
+ my $ref_card;
|
|
||||||
+
|
|
||||||
+ return "ZZ" if $ref == 0x1f;
|
|
||||||
+ $ref += 0x1f if $rrc & 0x80;
|
|
||||||
+ $revision = (($rrc >> 5) & 0x03) if $revision == 0;
|
|
||||||
+
|
|
||||||
+ if ($ref < length($alphabet)) {
|
|
||||||
+ # One letter reference card
|
|
||||||
+ $ref_card = substr($alphabet, $ref, 1);
|
|
||||||
+ } else {
|
|
||||||
+ # Two letter reference card
|
|
||||||
+ my $ref1 = int($ref / (length($alphabet)));
|
|
||||||
+ $ref -= length($alphabet) * $ref1;
|
|
||||||
+ $ref_card = substr($alphabet, $ref1, 1) .
|
|
||||||
+ substr($alphabet, $ref, 1);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return "$ref_card revision $revision";
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+sub ddr3_revision_number($)
|
|
||||||
+{
|
|
||||||
+ my $h = $_[0] >> 4;
|
|
||||||
+ my $l = $_[0] & 0x0f;
|
|
||||||
+
|
|
||||||
+ # Decode as suggested by JEDEC Standard 21-C
|
|
||||||
+ return sprintf("%d", $l) if $h == 0;
|
|
||||||
+ return sprintf("%d.%d", $h, $l) if $h < 0xa;
|
|
||||||
+ return sprintf("%c%d", ord('A') + $h - 0xa, $l);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+sub ddr3_device_type($)
|
|
||||||
+{
|
|
||||||
+ my $byte = shift;
|
|
||||||
+ my $type = $byte & 0x80 ? "Non-Standard" : "Standard Monolithic";
|
|
||||||
+ my $die_count = ($byte >> 4) & 0x07;
|
|
||||||
+ my $loading = ($byte >> 2) & 0x03;
|
|
||||||
+
|
|
||||||
+ if ($die_count == 1) {
|
|
||||||
+ $type .= "\nSingle die";
|
|
||||||
+ } elsif ($die_count == 2) {
|
|
||||||
+ $type .= "\n2 die";
|
|
||||||
+ } elsif ($die_count == 3) {
|
|
||||||
+ $type .= "\n4 die";
|
|
||||||
+ } elsif ($die_count == 4) {
|
|
||||||
+ $type .= "\n8 die";
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if ($loading == 1) {
|
|
||||||
+ $type .= "\nMulti load stack";
|
|
||||||
+ } elsif ($loading == 2) {
|
|
||||||
+ $type .= "\nSingle load stack";
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return $type;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+use constant DDR3_UNBUFFERED => 1;
|
|
||||||
+use constant DDR3_REGISTERED => 2;
|
|
||||||
+use constant DDR3_CLOCKED => 3;
|
|
||||||
+use constant DDR3_LOAD_REDUCED => 4;
|
|
||||||
+
|
|
||||||
# Parameter: EEPROM bytes 0-127 (using 3-76)
|
|
||||||
sub decode_ddr3_sdram($)
|
|
||||||
{
|
|
||||||
my $bytes = shift;
|
|
||||||
my $temp;
|
|
||||||
my $ctime;
|
|
||||||
+ my ($ftb, $mtb);
|
|
||||||
+ my $ii;
|
|
||||||
|
|
||||||
- my @module_types = ("Undefined", "RDIMM", "UDIMM", "SO-DIMM",
|
|
||||||
- "Micro-DIMM", "Mini-RDIMM", "Mini-UDIMM",
|
|
||||||
- "Mini-CDIMM", "72b-SO-UDIMM", "72b-SO-RDIMM",
|
|
||||||
- "72b-SO-CDIMM", "LRDIMM", "16b-SO-DIMM",
|
|
||||||
- "32b-SO-DIMM");
|
|
||||||
+ my @module_types = (
|
|
||||||
+ { type => "Undefined", width => "Unknown" },
|
|
||||||
+ { type => "RDIMM", width => "133.35 mm", family => DDR3_REGISTERED },
|
|
||||||
+ { type => "UDIMM", width => "133.35 mm", family => DDR3_UNBUFFERED },
|
|
||||||
+ { type => "SO-DIMM", width => "67.6 mm", family => DDR3_UNBUFFERED },
|
|
||||||
+ { type => "Micro-DIMM", width => "TBD", family => DDR3_UNBUFFERED },
|
|
||||||
+ { type => "Mini-RDIMM", width => "82.0 mm", family => DDR3_REGISTERED },
|
|
||||||
+ { type => "Mini-UDIMM", width => "82.0 mm", family => DDR3_UNBUFFERED },
|
|
||||||
+ { type => "Mini-CDIMM", width => "67.6 mm", family => DDR3_CLOCKED },
|
|
||||||
+ { type => "72b-SO-UDIMM", width => "67.6 mm", family => DDR3_UNBUFFERED },
|
|
||||||
+ { type => "72b-SO-RDIMM", width => "67.6 mm", family => DDR3_REGISTERED },
|
|
||||||
+ { type => "72b-SO-CDIMM", width => "67.6 mm", family => DDR3_CLOCKED },
|
|
||||||
+ { type => "LRDIMM", width => "133.35 mm", family => DDR3_LOAD_REDUCED },
|
|
||||||
+ { type => "16b-SO-DIMM", width => "67.6 mm", family => DDR3_UNBUFFERED },
|
|
||||||
+ { type => "32b-SO-DIMM", width => "67.6 mm", family => DDR3_UNBUFFERED },
|
|
||||||
+ );
|
|
||||||
|
|
||||||
printl("Module Type", ($bytes->[3] <= $#module_types) ?
|
|
||||||
- $module_types[$bytes->[3]] :
|
|
||||||
+ $module_types[$bytes->[3]]->{type} :
|
|
||||||
sprintf("Reserved (0x%.2X)", $bytes->[3]));
|
|
||||||
|
|
||||||
+# time bases
|
|
||||||
+ if (($bytes->[9] & 0x0f) == 0 || $bytes->[11] == 0) {
|
|
||||||
+ print STDERR "Invalid time base divisor, can't decode\n";
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ $ftb = ($bytes->[9] >> 4) / ($bytes->[9] & 0x0f);
|
|
||||||
+ $mtb = $bytes->[10] / $bytes->[11];
|
|
||||||
+
|
|
||||||
# speed
|
|
||||||
prints("Memory Characteristics");
|
|
||||||
|
|
||||||
- my $dividend = ($bytes->[9] >> 4) & 15;
|
|
||||||
- my $divisor = $bytes->[9] & 15;
|
|
||||||
- printl("Fine time base", sprintf("%.3f", $dividend / $divisor) . " ps");
|
|
||||||
-
|
|
||||||
- $dividend = $bytes->[10];
|
|
||||||
- $divisor = $bytes->[11];
|
|
||||||
- my $mtb = $dividend / $divisor;
|
|
||||||
- printl("Medium time base", tns3($mtb));
|
|
||||||
+ $ctime = ddr3_mtb_ftb($bytes->[12], $bytes->[34], $mtb, $ftb);
|
|
||||||
+ # Starting with DDR3-1866, vendors may start approximating the
|
|
||||||
+ # minimum cycle time. Try to guess what they really meant so
|
|
||||||
+ # that the reported speed matches the standard.
|
|
||||||
+ for ($ii = 7; $ii < 15; $ii++) {
|
|
||||||
+ if ($ctime > 7.5/$ii - $ftb/1000 && $ctime < 7.5/$ii + $ftb/1000) {
|
|
||||||
+ $ctime = 7.5/$ii;
|
|
||||||
+ last;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
|
|
||||||
- $ctime = $bytes->[12] * $mtb;
|
|
||||||
my $ddrclk = 2 * (1000 / $ctime);
|
|
||||||
my $tbits = 1 << (($bytes->[8] & 7) + 3);
|
|
||||||
my $pcclk = int ($ddrclk * $tbits / 8);
|
|
||||||
@@ -1249,17 +1350,16 @@ sub decode_ddr3_sdram($)
|
|
||||||
my $trp;
|
|
||||||
my $tras;
|
|
||||||
|
|
||||||
- $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]);
|
|
||||||
+ $taa = ddr3_mtb_ftb($bytes->[16], $bytes->[35], $mtb, $ftb);
|
|
||||||
+ $trcd = ddr3_mtb_ftb($bytes->[18], $bytes->[36], $mtb, $ftb);
|
|
||||||
+ $trp = ddr3_mtb_ftb($bytes->[20], $bytes->[37], $mtb, $ftb);
|
|
||||||
+ $tras = ((($bytes->[21] & 0x0f) << 8) + $bytes->[22]) * $mtb;
|
|
||||||
|
|
||||||
- printl("tCL-tRCD-tRP-tRAS", join("-", $taa, $trcd, $trp, $tras));
|
|
||||||
+ printl("tCL-tRCD-tRP-tRAS", ddr_core_timings(ceil($taa / $ctime), $ctime, $trcd, $trp, $tras));
|
|
||||||
|
|
||||||
# latencies
|
|
||||||
my $highestCAS = 0;
|
|
||||||
my %cas;
|
|
||||||
- my $ii;
|
|
||||||
my $cas_sup = ($bytes->[15] << 8) + $bytes->[14];
|
|
||||||
for ($ii = 0; $ii < 15; $ii++) {
|
|
||||||
if ($cas_sup & (1 << $ii)) {
|
|
||||||
@@ -1269,14 +1369,38 @@ sub decode_ddr3_sdram($)
|
|
||||||
}
|
|
||||||
printl("Supported CAS Latencies (tCL)", cas_latencies(keys %cas));
|
|
||||||
|
|
||||||
+# standard DDR3 speeds
|
|
||||||
+ prints("Timings at Standard Speeds");
|
|
||||||
+ foreach my $ctime_at_speed (7.5/8, 7.5/7, 1.25, 1.5, 1.875, 2.5) {
|
|
||||||
+ my $best_cas = 0;
|
|
||||||
+
|
|
||||||
+ # Find min CAS latency at this speed
|
|
||||||
+ for ($ii = 14; $ii >= 0; $ii--) {
|
|
||||||
+ next unless ($cas_sup & (1 << $ii));
|
|
||||||
+ if (ceil($taa / $ctime_at_speed) <= $ii + 4) {
|
|
||||||
+ $best_cas = $ii + 4;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ printl_cond($best_cas && $ctime_at_speed >= $ctime,
|
|
||||||
+ "tCL-tRCD-tRP-tRAS" . as_ddr(3, $ctime_at_speed),
|
|
||||||
+ ddr_core_timings($best_cas, $ctime_at_speed,
|
|
||||||
+ $trcd, $trp, $tras));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
# more timing information
|
|
||||||
prints("Timing Parameters");
|
|
||||||
|
|
||||||
+ printl("Minimum Cycle Time (tCK)", tns3($ctime));
|
|
||||||
+ printl("Minimum CAS Latency Time (tAA)", tns3($taa));
|
|
||||||
printl("Minimum Write Recovery time (tWR)", tns3($bytes->[17] * $mtb));
|
|
||||||
+ printl("Minimum RAS# to CAS# Delay (tRCD)", tns3($trcd));
|
|
||||||
printl("Minimum Row Active to Row Active Delay (tRRD)",
|
|
||||||
tns3($bytes->[19] * $mtb));
|
|
||||||
+ printl("Minimum Row Precharge Delay (tRP)", tns3($trp));
|
|
||||||
+ printl("Minimum Active to Precharge Delay (tRAS)", tns3($tras));
|
|
||||||
printl("Minimum Active to Auto-Refresh Delay (tRC)",
|
|
||||||
- tns3((((($bytes->[21] >> 4) & 15) << 8) + $bytes->[23]) * $mtb));
|
|
||||||
+ tns3(ddr3_mtb_ftb((($bytes->[21] & 0xf0) << 4) + $bytes->[23], $bytes->[38], $mtb, $ftb)));
|
|
||||||
printl("Minimum Recovery Delay (tRFC)",
|
|
||||||
tns3((($bytes->[25] << 8) + $bytes->[24]) * $mtb));
|
|
||||||
printl("Minimum Write to Read CMD Delay (tWTR)",
|
|
||||||
@@ -1312,43 +1436,31 @@ sub decode_ddr3_sdram($)
|
|
||||||
($bytes->[31] & 8) ? "Yes" : "No");
|
|
||||||
printl("Partial Array Self-Refresh?",
|
|
||||||
($bytes->[31] & 128) ? "Yes" : "No");
|
|
||||||
- printl("Thermal Sensor Accuracy",
|
|
||||||
- ($bytes->[32] & 128) ? sprintf($bytes->[32] & 127) :
|
|
||||||
- "Not implemented");
|
|
||||||
- printl("SDRAM Device Type",
|
|
||||||
- ($bytes->[33] & 128) ? sprintf($bytes->[33] & 127) :
|
|
||||||
- "Standard Monolithic");
|
|
||||||
- if ($bytes->[3] >= 1 && $bytes->[3] <= 6) {
|
|
||||||
-
|
|
||||||
+ printl("Module Thermal Sensor",
|
|
||||||
+ ($bytes->[32] & 128) ? "Yes" : "No");
|
|
||||||
+ printl("SDRAM Device Type", ddr3_device_type($bytes->[33]));
|
|
||||||
+
|
|
||||||
+ # Following bytes are type-specific, so don't continue if type
|
|
||||||
+ # isn't known.
|
|
||||||
+ return if $bytes->[3] == 0 || $bytes->[3] > $#module_types;
|
|
||||||
+
|
|
||||||
+ if ($module_types[$bytes->[3]]->{family} == DDR3_UNBUFFERED ||
|
|
||||||
+ $module_types[$bytes->[3]]->{family} == DDR3_REGISTERED ||
|
|
||||||
+ $module_types[$bytes->[3]]->{family} == DDR3_CLOCKED ||
|
|
||||||
+ $module_types[$bytes->[3]]->{family} == DDR3_LOAD_REDUCED) {
|
|
||||||
prints("Physical Characteristics");
|
|
||||||
- printl("Module Height (mm)", ($bytes->[60] & 31) + 15);
|
|
||||||
- printl("Module Thickness (mm)", sprintf("%d front, %d back",
|
|
||||||
+ printl("Module Height", (($bytes->[60] & 31) + 15) . " mm");
|
|
||||||
+ printl("Module Thickness", sprintf("%d mm front, %d mm back",
|
|
||||||
($bytes->[61] & 15) + 1,
|
|
||||||
(($bytes->[61] >> 4) & 15) +1));
|
|
||||||
- printl("Module Width (mm)", ($bytes->[3] <= 2) ? 133.5 :
|
|
||||||
- ($bytes->[3] == 3) ? 67.6 : "TBD");
|
|
||||||
+ printl("Module Width", $module_types[$bytes->[3]]->{width});
|
|
||||||
+ printl("Module Reference Card", ddr3_reference_card($bytes->[62], $bytes->[60]));
|
|
||||||
|
|
||||||
- my $alphabet = "ABCDEFGHJKLMNPRTUVWY";
|
|
||||||
- my $ref = $bytes->[62] & 31;
|
|
||||||
- my $ref_card;
|
|
||||||
- if ($ref == 31) {
|
|
||||||
- $ref_card = "ZZ";
|
|
||||||
- } else {
|
|
||||||
- if ($bytes->[62] & 128) {
|
|
||||||
- $ref += 31;
|
|
||||||
- }
|
|
||||||
- if ($ref < length $alphabet) {
|
|
||||||
- $ref_card = substr $alphabet, $ref, 1;
|
|
||||||
- } else {
|
|
||||||
- my $ref1 = int($ref / (length $alphabet));
|
|
||||||
- $ref -= (length $alphabet) * $ref1;
|
|
||||||
- $ref_card = (substr $alphabet, $ref1, 1) .
|
|
||||||
- (substr $alphabet, $ref, 1);
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- printl("Module Reference Card", $ref_card);
|
|
||||||
+ printl_cond($module_types[$bytes->[3]]->{family} == DDR3_UNBUFFERED,
|
|
||||||
+ "Rank 1 Mapping", $bytes->[63] & 0x01 ? "Mirrored" : "Standard");
|
|
||||||
}
|
|
||||||
- if ($bytes->[3] == 1 || $bytes->[3] == 5) {
|
|
||||||
+
|
|
||||||
+ if ($module_types[$bytes->[3]]->{family} == DDR3_REGISTERED) {
|
|
||||||
prints("Registered DIMM");
|
|
||||||
|
|
||||||
my @rows = ("Undefined", 1, 2, 4);
|
|
||||||
@@ -1359,17 +1471,27 @@ sub decode_ddr3_sdram($)
|
|
||||||
printl("Register device type",
|
|
||||||
(($bytes->[68] & 7) == 0) ? "SSTE32882" :
|
|
||||||
"Undefined");
|
|
||||||
- printl("Register revision", sprintf("0x%.2X", $bytes->[67]));
|
|
||||||
- printl("Heat spreader characteristics",
|
|
||||||
- ($bytes->[64] < 128) ? "Not incorporated" :
|
|
||||||
- sprintf("%.2X", ($bytes->[64] & 127)));
|
|
||||||
- my $regs;
|
|
||||||
- for (my $i = 0; $i < 8; $i++) {
|
|
||||||
- $regs = sprintf("SSTE32882 RC%d/RC%d",
|
|
||||||
- $i * 2, $i * 2 + 1);
|
|
||||||
- printl($regs, sprintf("%.2X", $bytes->[$i + 69]));
|
|
||||||
- }
|
|
||||||
+ printl_cond($bytes->[67] != 0xff,
|
|
||||||
+ "Register revision", ddr3_revision_number($bytes->[67]));
|
|
||||||
+ printl("Heat spreader", $bytes->[64] & 0x80 ? "Yes" : "No");
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if ($module_types[$bytes->[3]]->{family} == DDR3_LOAD_REDUCED) {
|
|
||||||
+ prints("Load Reduced DIMM");
|
|
||||||
+
|
|
||||||
+ my @rows = ("Undefined", 1, 2, "Reserved");
|
|
||||||
+ printl("# DRAM Rows", $rows[($bytes->[63] >> 2) & 3]);
|
|
||||||
+ my @mirroring = ("None", "Odd ranks", "Reserved", "Reserved");
|
|
||||||
+ printl("Mirroring", $mirroring[$bytes->[63] & 3]);
|
|
||||||
+ printl("Rank Numbering", $bytes->[63] & 0x20 ? "Even only" : "Contiguous");
|
|
||||||
+ printl("Buffer Orientation", $bytes->[63] & 0x10 ? "Horizontal" : "Vertical");
|
|
||||||
+ printl("Register manufacturer",
|
|
||||||
+ manufacturer_ddr3($bytes->[65], $bytes->[66]));
|
|
||||||
+ printl_cond($bytes->[64] != 0xff,
|
|
||||||
+ "Buffer Revision", ddr3_revision_number($bytes->[64]));
|
|
||||||
+ printl("Heat spreader", $bytes->[63] & 0x80 ? "Yes" : "No");
|
|
||||||
}
|
|
||||||
+
|
|
||||||
}
|
|
||||||
|
|
||||||
# Parameter: EEPROM bytes 0-127 (using 4-5)
|
|
||||||
@@ -1470,26 +1592,23 @@ sub decode_ddr3_mfg_data($)
|
|
||||||
printl("Module Manufacturer",
|
|
||||||
manufacturer_ddr3($bytes->[117], $bytes->[118]));
|
|
||||||
|
|
||||||
- if (spd_written(@{$bytes}[148..149])) {
|
|
||||||
- printl("DRAM Manufacturer",
|
|
||||||
- manufacturer_ddr3($bytes->[148], $bytes->[149]));
|
|
||||||
- }
|
|
||||||
+ printl_cond(spd_written(@{$bytes}[148..149]),
|
|
||||||
+ "DRAM Manufacturer",
|
|
||||||
+ manufacturer_ddr3($bytes->[148], $bytes->[149]));
|
|
||||||
|
|
||||||
printl_mfg_location_code($bytes->[119]);
|
|
||||||
|
|
||||||
- if (spd_written(@{$bytes}[120..121])) {
|
|
||||||
- printl("Manufacturing Date",
|
|
||||||
- manufacture_date($bytes->[120], $bytes->[121]));
|
|
||||||
- }
|
|
||||||
+ printl_cond(spd_written(@{$bytes}[120..121]),
|
|
||||||
+ "Manufacturing Date",
|
|
||||||
+ manufacture_date($bytes->[120], $bytes->[121]));
|
|
||||||
|
|
||||||
printl_mfg_assembly_serial(@{$bytes}[122..125]);
|
|
||||||
|
|
||||||
printl("Part Number", part_number(@{$bytes}[128..145]));
|
|
||||||
|
|
||||||
- if (spd_written(@{$bytes}[146..147])) {
|
|
||||||
- printl("Revision Code",
|
|
||||||
- sprintf("0x%02X%02X", $bytes->[146], $bytes->[147]));
|
|
||||||
- }
|
|
||||||
+ printl_cond(spd_written(@{$bytes}[146..147]),
|
|
||||||
+ "Revision Code",
|
|
||||||
+ sprintf("0x%02X%02X", $bytes->[146], $bytes->[147]));
|
|
||||||
}
|
|
||||||
|
|
||||||
# Parameter: EEPROM bytes 0-127 (using 64-98)
|
|
@ -1,451 +0,0 @@
|
|||||||
From 3ceb5a7870cb236981b7c3b5c5b9665dcb1ebe27 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jean Delvare <khali@linux-fr.org>
|
|
||||||
Date: Thu, 26 Apr 2012 10:10:22 +0000
|
|
||||||
Subject: [PATCH] i2c-dev: Move SMBus helper functions to include/i2c/smbus.h
|
|
||||||
|
|
||||||
git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@6048 7894878c-1315-0410-8ee3-d5d059ff63e0
|
|
||||||
---
|
|
||||||
eepromer/24cXX.c | 3 +
|
|
||||||
eepromer/24cXX.h | 2 +-
|
|
||||||
eepromer/eeprom.c | 2 +
|
|
||||||
eepromer/eepromer.c | 2 +
|
|
||||||
include/Module.mk | 6 +-
|
|
||||||
include/linux/i2c-dev.h | 257 ------------------------------------------------
|
|
||||||
py-smbus/Module.mk | 2 +-
|
|
||||||
py-smbus/smbusmodule.c | 3 +
|
|
||||||
tools/Module.mk | 12 +--
|
|
||||||
tools/i2cbusses.c | 4 +-
|
|
||||||
tools/i2cdetect.c | 5 +-
|
|
||||||
tools/i2cdump.c | 5 +-
|
|
||||||
tools/i2cget.c | 5 +-
|
|
||||||
tools/i2cset.c | 5 +-
|
|
||||||
15 files changed, 41 insertions(+), 273 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/Module.mk b/include/Module.mk
|
|
||||||
index fda7cfb..4a9713c 100644
|
|
||||||
--- a/include/Module.mk
|
|
||||||
+++ b/include/Module.mk
|
|
||||||
@@ -9,14 +9,14 @@
|
|
||||||
|
|
||||||
INCLUDE_DIR := include
|
|
||||||
|
|
||||||
-INCLUDE_TARGETS := linux/i2c-dev.h
|
|
||||||
+INCLUDE_TARGETS := i2c/smbus.h
|
|
||||||
|
|
||||||
#
|
|
||||||
# Commands
|
|
||||||
#
|
|
||||||
|
|
||||||
install-include: $(addprefix $(INCLUDE_DIR)/,$(INCLUDE_TARGETS))
|
|
||||||
- $(INSTALL_DIR) $(DESTDIR)$(incdir)/linux
|
|
||||||
+ $(INSTALL_DIR) $(DESTDIR)$(incdir)/i2c
|
|
||||||
for file in $(INCLUDE_TARGETS) ; do \
|
|
||||||
$(INSTALL_DATA) $(INCLUDE_DIR)/$$file $(DESTDIR)$(incdir)/$$file ; done
|
|
||||||
|
|
||||||
diff --git a/include/linux/i2c-dev.h b/include/linux/i2c-dev.h
|
|
||||||
index 23f7c2c..64166c6 100644
|
|
||||||
--- a/include/linux/i2c-dev.h
|
|
||||||
+++ b/include/linux/i2c-dev.h
|
|
||||||
@@ -24,91 +24,9 @@
|
|
||||||
#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
|
|
||||||
* unsigned long, except for:
|
|
||||||
@@ -153,178 +71,4 @@ 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 */
|
|
||||||
diff --git a/py-smbus/Module.mk b/py-smbus/Module.mk
|
|
||||||
index 138a789..fc2b201 100644
|
|
||||||
--- a/py-smbus/Module.mk
|
|
||||||
+++ b/py-smbus/Module.mk
|
|
||||||
@@ -14,7 +14,7 @@ DISTUTILS := \
|
|
||||||
cd $(PY_SMBUS_DIR) && \
|
|
||||||
CPPFLAGS="$(CPPFLAGS) -I../include" $(PYTHON) setup.py
|
|
||||||
|
|
||||||
-all-python: $(INCLUDE_DIR)/linux/i2c-dev.h
|
|
||||||
+all-python: $(INCLUDE_DIR)/i2c/smbus.h
|
|
||||||
$(DISTUTILS) build
|
|
||||||
|
|
||||||
clean-python:
|
|
||||||
diff --git a/py-smbus/smbusmodule.c b/py-smbus/smbusmodule.c
|
|
||||||
index 86e8e13..d360a36 100644
|
|
||||||
--- a/py-smbus/smbusmodule.c
|
|
||||||
+++ b/py-smbus/smbusmodule.c
|
|
||||||
@@ -22,7 +22,9 @@
|
|
||||||
#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.
|
|
||||||
diff --git a/tools/Module.mk b/tools/Module.mk
|
|
||||||
index 8ad8fc0..33ae774 100644
|
|
||||||
--- a/tools/Module.mk
|
|
||||||
+++ b/tools/Module.mk
|
|
||||||
@@ -1,6 +1,6 @@
|
|
||||||
# I2C tools for Linux
|
|
||||||
#
|
|
||||||
-# Copyright (C) 2007 Jean Delvare <jdelvare@suse.de>
|
|
||||||
+# Copyright (C) 2007, 2012 Jean Delvare <khali@linux-fr.org>
|
|
||||||
#
|
|
||||||
# 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
|
|
||||||
@@ -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)/linux/i2c-dev.h
|
|
||||||
+$(TOOLS_DIR)/i2cdetect.o: $(TOOLS_DIR)/i2cdetect.c $(TOOLS_DIR)/i2cbusses.h $(INCLUDE_DIR)/i2c/smbus.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)/linux/i2c-dev.h
|
|
||||||
+$(TOOLS_DIR)/i2cdump.o: $(TOOLS_DIR)/i2cdump.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/i2c/smbus.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)/linux/i2c-dev.h
|
|
||||||
+$(TOOLS_DIR)/i2cset.o: $(TOOLS_DIR)/i2cset.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/i2c/smbus.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)/linux/i2c-dev.h
|
|
||||||
+$(TOOLS_DIR)/i2cget.o: $(TOOLS_DIR)/i2cget.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/i2c/smbus.h
|
|
||||||
$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
-$(TOOLS_DIR)/i2cbusses.o: $(TOOLS_DIR)/i2cbusses.c $(TOOLS_DIR)/i2cbusses.h $(INCLUDE_DIR)/linux/i2c-dev.h
|
|
||||||
+$(TOOLS_DIR)/i2cbusses.o: $(TOOLS_DIR)/i2cbusses.c $(TOOLS_DIR)/i2cbusses.h
|
|
||||||
$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
$(TOOLS_DIR)/util.o: $(TOOLS_DIR)/util.c $(TOOLS_DIR)/util.h
|
|
||||||
diff --git a/tools/i2cbusses.c b/tools/i2cbusses.c
|
|
||||||
index 7a1b7cb..b3093aa 100644
|
|
||||||
--- a/tools/i2cbusses.c
|
|
||||||
+++ b/tools/i2cbusses.c
|
|
||||||
@@ -39,6 +39,7 @@
|
|
||||||
#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 };
|
|
||||||
diff --git a/tools/i2cdetect.c b/tools/i2cdetect.c
|
|
||||||
index 07b3d97..675a150 100644
|
|
||||||
--- a/tools/i2cdetect.c
|
|
||||||
+++ b/tools/i2cdetect.c
|
|
||||||
@@ -26,7 +26,9 @@
|
|
||||||
#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"
|
|
||||||
|
|
||||||
diff --git a/tools/i2cdump.c b/tools/i2cdump.c
|
|
||||||
index 2fc98fd..a7bba72 100644
|
|
||||||
--- a/tools/i2cdump.c
|
|
||||||
+++ b/tools/i2cdump.c
|
|
||||||
@@ -26,7 +26,9 @@
|
|
||||||
#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"
|
|
||||||
diff --git a/tools/i2cget.c b/tools/i2cget.c
|
|
||||||
index 7053d0f..2503942 100644
|
|
||||||
--- a/tools/i2cget.c
|
|
||||||
+++ b/tools/i2cget.c
|
|
||||||
@@ -29,7 +29,9 @@
|
|
||||||
#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"
|
|
||||||
diff --git a/tools/i2cset.c b/tools/i2cset.c
|
|
||||||
index e143b65..0ccc1a0 100644
|
|
||||||
--- a/tools/i2cset.c
|
|
||||||
+++ b/tools/i2cset.c
|
|
||||||
@@ -26,7 +26,9 @@
|
|
||||||
#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"
|
|
@ -1,229 +0,0 @@
|
|||||||
From dbabf68c5b04a85b6fb457c539f304a84cd62eef Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jean Delvare <khali@linux-fr.org>
|
|
||||||
Date: Mon, 21 May 2012 16:46:51 +0000
|
|
||||||
Subject: [PATCH] Add header file missed from a previous commit.
|
|
||||||
|
|
||||||
git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@6053 7894878c-1315-0410-8ee3-d5d059ff63e0
|
|
||||||
---
|
|
||||||
include/i2c/smbus.h | 212 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
1 file changed, 212 insertions(+)
|
|
||||||
create mode 100644 include/i2c/smbus.h
|
|
||||||
|
|
||||||
diff --git a/include/i2c/smbus.h b/include/i2c/smbus.h
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..bf7ed37
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/include/i2c/smbus.h
|
|
||||||
@@ -0,0 +1,212 @@
|
|
||||||
+/*
|
|
||||||
+ smbus.h - SMBus level access helper functions
|
|
||||||
+
|
|
||||||
+ Copyright (C) 1995-97 Simon G. Vogl
|
|
||||||
+ Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
|
|
||||||
+
|
|
||||||
+ 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.
|
|
||||||
+*/
|
|
||||||
+
|
|
||||||
+#ifndef LIB_I2C_SMBUS_H
|
|
||||||
+#define LIB_I2C_SMBUS_H
|
|
||||||
+
|
|
||||||
+#include <sys/ioctl.h>
|
|
||||||
+#include <linux/types.h>
|
|
||||||
+#include <linux/i2c.h>
|
|
||||||
+#include <linux/i2c-dev.h>
|
|
||||||
+
|
|
||||||
+/* Compatibility defines */
|
|
||||||
+#ifndef I2C_SMBUS_I2C_BLOCK_BROKEN
|
|
||||||
+#define I2C_SMBUS_I2C_BLOCK_BROKEN I2C_SMBUS_I2C_BLOCK_DATA
|
|
||||||
+#endif
|
|
||||||
+#ifndef I2C_FUNC_SMBUS_PEC
|
|
||||||
+#define I2C_FUNC_SMBUS_PEC I2C_FUNC_SMBUS_HWPEC_CALC
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+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 /* LIB_I2C_SMBUS_H */
|
|
@ -1,3 +1,23 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Oct 30 15:57:32 CET 2017 - jdelvare@suse.com
|
||||||
|
|
||||||
|
- i2cbusses-path-overflows.patch: Prevent buffer overflow of
|
||||||
|
sysfs paths.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Oct 30 11:45:40 CET 2017 - jdelvare@suse.com
|
||||||
|
|
||||||
|
- Update to version 4.0:
|
||||||
|
* New library libi2c
|
||||||
|
* Many fixes and improvements to decode-dimms
|
||||||
|
* New manual pages and examples added to existing manual pages
|
||||||
|
* New tool i2ctransfer
|
||||||
|
- Removed obsolete decode-dimms-correctly-check-for-out-of-bounds-vendor-id.patch,
|
||||||
|
i2c-tools-hackweek-9-dependencies.diff,
|
||||||
|
i2c-tools-hackweek-9-improve-DDR3-support.diff,
|
||||||
|
i2c-tools-r6048-Move-SMBus-helper-functions.patch,
|
||||||
|
i2c-tools-r6053-Add-smbus-header.patch (upstream)
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Jul 17 14:56:43 CEST 2017 - jdelvare@suse.com
|
Mon Jul 17 14:56:43 CEST 2017 - jdelvare@suse.com
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
|
|
||||||
Name: i2c-tools
|
Name: i2c-tools
|
||||||
Version: 3.1.2
|
Version: 4.0
|
||||||
Release: 0
|
Release: 0
|
||||||
Summary: A heterogeneous set of I2C tools for Linux
|
Summary: A heterogeneous set of I2C tools for Linux
|
||||||
License: GPL-2.0+
|
License: GPL-2.0+
|
||||||
@ -27,11 +27,7 @@ Recommends: modules
|
|||||||
Url: https://i2c.wiki.kernel.org/index.php/I2C_Tools
|
Url: https://i2c.wiki.kernel.org/index.php/I2C_Tools
|
||||||
Source0: https://www.kernel.org/pub/software/utils/i2c-tools/%{name}-%{version}.tar.xz
|
Source0: https://www.kernel.org/pub/software/utils/i2c-tools/%{name}-%{version}.tar.xz
|
||||||
Source1: https://www.kernel.org/pub/software/utils/i2c-tools/%{name}-%{version}.tar.sign
|
Source1: https://www.kernel.org/pub/software/utils/i2c-tools/%{name}-%{version}.tar.sign
|
||||||
Patch90: i2c-tools-hackweek-9-dependencies.diff
|
Patch1: i2cbusses-path-overflows.patch
|
||||||
Patch91: i2c-tools-hackweek-9-improve-DDR3-support.diff
|
|
||||||
Patch92: i2c-tools-r6053-Add-smbus-header.patch
|
|
||||||
Patch93: i2c-tools-r6048-Move-SMBus-helper-functions.patch
|
|
||||||
Patch94: decode-dimms-correctly-check-for-out-of-bounds-vendor-id.patch
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
ExcludeArch: s390 s390x
|
ExcludeArch: s390 s390x
|
||||||
|
|
||||||
@ -40,29 +36,56 @@ This package contains a heterogeneous set of I2C tools for Linux: a bus
|
|||||||
probing tool, a chip dumper, register-level access helpers, EEPROM
|
probing tool, a chip dumper, register-level access helpers, EEPROM
|
||||||
decoding scripts, and more.
|
decoding scripts, and more.
|
||||||
|
|
||||||
|
%package -n libi2c0
|
||||||
|
Summary: I2C/SMBus bus access library
|
||||||
|
License: LGPL-2.1+
|
||||||
|
Group: System/Libraries
|
||||||
|
|
||||||
|
%description -n libi2c0
|
||||||
|
libi2c offers a way for applications to interact with the devices
|
||||||
|
connected to the I2C or SMBus buses of the system.
|
||||||
|
|
||||||
|
%package -n libi2c0-devel
|
||||||
|
Summary: I2C/SMBus bus access library
|
||||||
|
License: LGPL-2.1+
|
||||||
|
Group: Development/Libraries/C and C++
|
||||||
|
Requires: glibc-devel
|
||||||
|
Requires: libi2c0 = %{version}
|
||||||
|
Provides: /usr/include/i2c/smbus.h
|
||||||
|
|
||||||
|
%description -n libi2c0-devel
|
||||||
|
libi2c offers a way for applications to interact with the devices
|
||||||
|
connected to the I2C or SMBus buses of the system.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
%patch90 -p1
|
%patch1 -p1
|
||||||
%patch91 -p1
|
|
||||||
%patch92 -p1
|
|
||||||
%patch93 -p1
|
|
||||||
%patch94 -p1
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
make %{?_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" CC="%{__cc}"
|
make %{?_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" CC="%{__cc}" BUILD_STATIC_LIB:=0
|
||||||
|
|
||||||
%install
|
%install
|
||||||
make install DESTDIR=$RPM_BUILD_ROOT prefix=/usr
|
make install DESTDIR=$RPM_BUILD_ROOT prefix=/usr libdir=%{_libdir} BUILD_STATIC_LIB:=0
|
||||||
# cleanup
|
# cleanup
|
||||||
rm -f $RPM_BUILD_ROOT/usr/bin/decode-edid
|
rm -f $RPM_BUILD_ROOT/usr/bin/decode-edid
|
||||||
|
|
||||||
|
%post -n libi2c0 -p /sbin/ldconfig
|
||||||
|
|
||||||
|
%postun -n libi2c0 -p /sbin/ldconfig
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%defattr(-,root,root)
|
%defattr(-,root,root)
|
||||||
/usr/bin/*
|
/usr/bin/*
|
||||||
/usr/sbin/*
|
/usr/sbin/*
|
||||||
%dir /usr/include/i2c
|
|
||||||
/usr/include/i2c/smbus.h
|
|
||||||
%doc /usr/share/man/man1/*.1.gz
|
%doc /usr/share/man/man1/*.1.gz
|
||||||
%doc /usr/share/man/man8/*.8.gz
|
%doc /usr/share/man/man8/*.8.gz
|
||||||
|
|
||||||
|
%files -n libi2c0
|
||||||
|
%{_libdir}/libi2c.so.0*
|
||||||
|
|
||||||
|
%files -n libi2c0-devel
|
||||||
|
%{_libdir}/libi2c.so
|
||||||
|
%dir /usr/include/i2c
|
||||||
|
/usr/include/i2c/smbus.h
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
45
i2cbusses-path-overflows.patch
Normal file
45
i2cbusses-path-overflows.patch
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
From: Jean Delvare <jdelvare@suse.de>
|
||||||
|
Subject: i2c-tools: i2cbusses: Avoid buffer overflows in sysfs paths
|
||||||
|
Patch-mainline: yes
|
||||||
|
Git-commit: def2845efacab3a3973fb0218ac5077a162f8f1e
|
||||||
|
|
||||||
|
sprintf isn't safe, use snprintf instead.
|
||||||
|
---
|
||||||
|
tools/i2cbusses.c | 10 +++++-----
|
||||||
|
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
--- a/tools/i2cbusses.c
|
||||||
|
+++ b/tools/i2cbusses.c
|
||||||
|
@@ -220,18 +220,18 @@ 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);
|
||||||
|
+ snprintf(n, NAME_MAX, "%s/%s/name", sysfs, de->d_name);
|
||||||
|
f = fopen(n, "r");
|
||||||
|
/* this seems to work for ISA */
|
||||||
|
if(f == NULL) {
|
||||||
|
- sprintf(n, "%s/%s/device/name", sysfs, de->d_name);
|
||||||
|
+ snprintf(n, NAME_MAX, "%s/%s/device/name", sysfs, de->d_name);
|
||||||
|
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);
|
||||||
|
+ snprintf(n, NAME_MAX, "%s/%s/device", sysfs, de->d_name);
|
||||||
|
if(!(ddir = opendir(n)))
|
||||||
|
continue;
|
||||||
|
while ((dde = readdir(ddir)) != NULL) {
|
||||||
|
@@ -240,8 +240,8 @@ 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);
|
||||||
|
+ snprintf(n, NAME_MAX, "%s/%s/device/%s/name",
|
||||||
|
+ sysfs, de->d_name, dde->d_name);
|
||||||
|
if((f = fopen(n, "r")))
|
||||||
|
goto found;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user