Commit Graph

680 Commits

Author SHA1 Message Date
Alek Du 5bc1200852 i2c: Add Intel SCH SMBus support
New i2c bus driver for the Intel SCH chipsets (AF82US15W, AF82US15L,
AF82UL11L).

Signed-off-by: Alek Du <alek.du@intel.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:27 +02:00
Jean Delvare f7050bd716 i2c: Simplify i2c_del_driver()
i2c_del_driver() can be simplified a bit.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:26 +02:00
Matthias Kaehlcke 6a03cd9311 i2c: Use list_for_each_entry_safe
Use list_for_each_entry_safe() in i2c_del_adapter() and i2c_del_driver().

Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:26 +02:00
Wolfram Sang 7650da023e i2c-pca-platform: Fix error code
Fix errorcode to be more descriptive when ioremap fails.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:26 +02:00
Wolfram Sang c80ebe7987 i2c-pca-algo: Fix error code
Give a more concrete error code, when the bus is not idle.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:26 +02:00
Jean Delvare ac7fc4fb2b i2c: Consistently reject unsupported transactions
Many PC SMBus host controller drivers don't properly handle the case
where they are requested to achieve a transaction they do not support.
Update them so that the consistently print a warning message and
return a single error value in this case.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:25 +02:00
Jean Delvare fa63cd56d2 i2c-piix4: Various cleanups and minor fixes
The i2c-piix4 driver was used recently as a model to write a new SMBus
host controller driver and this made me realize that the code of this
old driver wasn't exactly good. So, here are many cleanups and minor
fixes to this driver, so that these minor mistakes aren't duplicated
again:

* Delete unused structure.
* Delete needless forward function declaration.
* Properly announce the SMBus host controller as we find it.
* Spell it SMBus not SMB.
* Return -EBUSY instead of -ENODEV when the I/O region is already in
  use.
* Drop useless masks on the 7-bit address and the R/W bit.
* Reject block transaction requests with an invalid block length.
* Check and report block transaction replies with an invalid block
  length.
* Delete a useless comment.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:25 +02:00
David Brownell 97140342e6 i2c: Bus drivers return -Errno not -1
Tighten error paths used by various i2c adapters (mostly x86) so
they return real fault/errno codes instead of a "-1" (which is
most often interpreted as "-EPERM").  Build tested, with eyeball
review.

One minor initial goal is to have adapters consistently return
the code "-ENXIO" when addressing a device doesn't get an ACK
response, at least in the probe paths where they are already
good at stifling related logspam.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:25 +02:00
David Brownell 6ea438ec8d i2c: i2c_use_client() defends against NULL
Defend the i2c refcount calls against NULL pointers, as is important
(and conventional) for such calls.  Note that none of the current
callers of i2c_use_client() use its return value.

[JD: I hate this but apparently all the other subsystems do it so...]

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:24 +02:00
David Brownell a1cdedac63 i2c: Kerneldoc for most I/O calls
Provide kerneldoc for most of the I2C and SMBus I/O calls.  Add a
comment summarizing some fault reporting issues which affect the
ability to provide clean fault reports through I2C master transfer
calls.  (Making it hard to precisely specify their return values...)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:24 +02:00
Jean Delvare 67c2e66571 i2c: Delete unused function i2c_smbus_write_quick
Function i2c_smbus_write_quick has no users left, so we can delete it.

Also update the list of these helper functions which are gone but
could be added back if needed.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:23 +02:00
Jean Delvare f5b728a164 i2c: Group bus drivers by type
The list of I2C/SMBus bus drivers is growing and it is sometimes
difficult for the users to figure out what drivers they should enable.
By grouping the drivers by type, I hope to make the selection easier.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:23 +02:00
David Brownell 24a5bb7b18 i2c-core: Return -Errno, not -1
More updates to the I2C stack's fault reporting:  make the core stop
returning "-1" (usually "-EPERM") for all faults.  Instead, pass lower
level fault code up the stack, or return some appropriate errno.

This patch happens to touch almost exclusively SMBus calls.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:23 +02:00
Jean Delvare 75415490d6 i2c-core: Remove needless include
i2c-core doesn't use seq files, so doesn't need to include
<linux/seq_file.h>.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:22 +02:00
Mike Frysinger 4d2bee582b i2c-bfin-twi: Update the dependencies
Since only a few Blackfins lack TWI, just list them in a depends
statement.

Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:22 +02:00
Adrian Bunk 20a9b6e7c3 i2c: Remove 3 deprecated bus drivers
This patch contains the scheduled removal of i2c-i810, i2c-prosavage
and i2c-savage4.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:22 +02:00
Jean Delvare 279e902445 i2c-nforce2: Add support for multiplexing on the Tyan S4985
Just like the Tyan S4882, the S4985 uses a multiplexer to give access
to all 16 memory module SPD EEPROMs. This specific i2c-nforce2-s4985
driver adds support for this. It is heavily based on the older
i2c-amd756-s4882 driver.

As more mainboards will use multiplexer chips, we will have to find a
way to support them without having to write a new specfic driver for
each. The recent changes to the i2c subsystem should help us, and the
new gpio subsystem might help, too.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:21 +02:00
Troy Kisky 2e74378798 i2c-davinci: Initialize cmd_complete sooner
If an interrupt happens before an I2c master read/write,
complete is called on uninitialized structure.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Signed-off-by: Kevin Hilman <khilman@mvista.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:21 +02:00
Troy Kisky 5a0d5f5ffa i2c-davinci: Fix signal handling bug
If wait_for_completion_interruptible_timeout exits due
to a signal, the i2c bus was locking up.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Signed-off-by: Kevin Hilman <khilman@mvista.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:21 +02:00
Troy Kisky 0ab56e2067 i2c-davinci: Remove useless IVR read
Interrupts are enabled at the point where the DAVINCI_I2C_IVR_REG is read,
so unless an interrupt happened just at that moment, no interrupt would be
pending. Even though documentation implies you should do this, I see no
reason. If slave support is added, this read would cause a hard to
reproduce bug.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Signed-off-by: Kevin Hilman <khilman@mvista.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:20 +02:00
Troy Kisky d868caa177 i2c-davinci: Move dev_dbg statement for more output
Previously the dev_dbg only printed if no error.
Printing also on an error is more useful

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Signed-off-by: Kevin Hilman <khilman@mvista.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:20 +02:00
Troy Kisky cc99ff70c7 i2c-davinci: Ensure clock between 7-12 MHz
Ensure psc value gives a clock between 7-12 MHz

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Signed-off-by: Kevin Hilman <khilman@mvista.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:20 +02:00
Dave Young 7f101a9786 i2c: Use class_for_each_device
Use class_for_each_device for iteration.

Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-14 22:38:19 +02:00
Ben Dooks d150a4bbd0 I2C: S3C2410: Add MODULE_ALIAS() for s3c2440 device.
Add a MODULE_ALIAS() statement for the i2c-s3c2410 controller
to ensure that it can be autoloaded on the S3C2440 systems that
we support.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
2008-07-01 14:30:38 +01:00
Ben Dooks 63f5c2891e I2C: S3C2410: Fixup error codes returned rom a transfer.
The driver should be returning -ENXIO for transfers that do not
pass the initial address byte stage.

Note, also small tidyups to the driver comments in the area.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
2008-07-01 14:30:37 +01:00
Ben Dooks 2709781be6 I2C: S3C2410: Check ACK on byte transmission
We should check for the reception of an ACK after transmitting each
data byte. The address send has been correctly checking this, but the
data write byte state should have also been checking for these failures.

As part of the same fix, we remove the ACK checking from the receive
path where it should not have been checking for an ACK which our hardware
was sending.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
2008-07-01 14:30:37 +01:00
Jean Delvare 70455e7903 i2c/max6875: Really prevent 24RF08 corruption
i2c-core takes care of the possible corruption of 24RF08 chips for
quite some times, so device devices no longer need to do it. And they
really should not, as applying the prevention twice voids it.

I thought that I had fixed all drivers long ago but apparently I had
missed that one.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Ben Gardner <bgardner@wabtec.com>
2008-05-18 20:49:41 +02:00
Jean Delvare 875b0a473c i2c-amd756: Fix functionality flags
The i2c-amd756 driver pretends to support SMBus process call
transactions but actually does not. Fix it.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-05-18 20:49:41 +02:00
Jean Delvare eb8a790809 i2c: Kill the old driver matching scheme
Remove the old driver_name/type scheme for i2c driver matching. Only the
standard aliasing model will be used from now on.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-05-18 20:49:41 +02:00
Jean Delvare 08851d6eb4 i2c-nforce2: Disable the second SMBus channel on the DFI Lanparty NF4 Expert
There is a strange chip at 0x2e on the second SMBus channel of the
DFI Lanparty NF4 Expert motherboard. Accessing the chip reboots the
system. As there's nothing interesting on this SMBus channel, the
easiest and safest thing to do is to disable it on that board.

This is a better fix to bug #5889 than the it87 driver update that was
done originally:
http://bugzilla.kernel.org/show_bug.cgi?id=5889

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-05-18 20:49:40 +02:00
Sergei Shtylyov 8e07c2c6af [MIPS] Alchemy: SMBus resource fix
The Alchemy platform code registers the SMBus device using the virtual
address of its registers instead of the physical one -- fix this, taking
into account that actually the whole megabyte is decoded by any of the
programmable serial controllers (one of which is SMBus), and that all the
Alchemy peripherals are directly mappable into KSEG1 kernel space and
therefore ioremap() call would just boil down to CKSEG1ADDR() invocation.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2008-05-12 16:46:50 +01:00
Jean Delvare 60b129d7bf i2c: Match dummy devices by type
As the old driver_name/type matching scheme is going away soon, change
the dummy device mechanism to use the new matching scheme.

This has the downside that dummy i2c clients can no longer choose
their name, they'll all appear as "dummy" in sysfs and in log
messages. I don't think it is a problem in practice though, as there
is little reason to use these i2c clients to log messages.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-05-11 20:37:06 +02:00
Maciej W. Rozycki b11a9d8392 i2c-sibyte: Mark i2c_sibyte_add_bus() as static
The i2c_sibyte_add_bus() function is not called, nor meant to, from 
outside, so mark it as static; fixing a sparse warning too.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-05-11 20:37:05 +02:00
Maciej W. Rozycki b3eb5a0bc3 i2c-sibyte: Correct a comment about frequency
The frequency may have been once hardcoded to 100 kHz, but currently it is
passed as an argument to i2c_sibyte_add_bus(), so update the comment to
match code.  While at it, reformat a nearby comment for consistency.  No
functional changes.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-05-11 20:37:05 +02:00
Jean Delvare c2fc54fcd3 i2c-piix4: Blacklist two mainboards
We had a report that running sensors-detect on a Sapphire AM2RD790
motherbord killed the CPU. While the exact cause is still unknown,
I'd rather play it safe and prevent any access to the SMBus on that
machine by not letting the i2c-piix4 driver attach to the SMBus host
device on that machine. Also blacklist a similar board made by DFI.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-05-11 20:37:05 +02:00
David Milburn b1c1759cd1 i2c-piix4: Increase the intitial delay for the ServerWorks CSB5
Per the PIIX4 errata, there maybe a delay between setting the
start bit in the Smbus Host Controller Register and the transaction
actually starting. If the driver doesn't delay long enough, it
may appear that the transaction is complete when actually it
hasn't started, this may lead to bus collisions.

While 1 ms appears to be enough for most chips, the ServerWorks CSB5
wants 2 ms.

Signed-off-by: David Milburn <dmilburn@redhat.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-05-11 20:37:05 +02:00
Jon Smirl f5fff3602a i2c-mpc: Compare to NO_IRQ instead of zero
Alter the mpc i2c driver to use the NO_IRQ symbol instead of the constant
zero when checking for valid interrupts. NO_IRQ=-1 on ppc and NO_IRQ=0 on
powerpc so the checks against zero are not correct.

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-05-11 20:37:04 +02:00
Jean Delvare 3760f73671 i2c: Convert most new-style drivers to use module aliasing
Based on earlier work by Jon Smirl and Jochen Friedrich.

Update most new-style i2c drivers to use standard module aliasing
instead of the old driver_name/type driver matching scheme. I've
left the video drivers apart (except for SoC camera drivers) as
they're a bit more diffcult to deal with, they'll have their own
patch later.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Jon Smirl <jonsmirl@gmail.com>
Cc: Jochen Friedrich <jochen@scram.de>
2008-04-29 23:11:40 +02:00
Jean Delvare d2653e9273 i2c: Add support for device alias names
Based on earlier work by Jon Smirl and Jochen Friedrich.

This patch allows new-style i2c chip drivers to have alias names using
the official kernel aliasing system and MODULE_DEVICE_TABLE(). At this
point, the old i2c driver binding scheme (driver_name/type) is still
supported.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Jochen Friedrich <jochen@scram.de>
Cc: Jon Smirl <jonsmirl@gmail.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
2008-04-29 23:11:39 +02:00
Jean Delvare ee56d97742 i2c-amd756-s4882: Fix an error path
If initialization fails, we want to restore the physical bus, not delete
it again.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-04-29 23:11:38 +02:00
Jean Delvare 6d072d78f8 i2c/tps65010: Add missing intialization of client data
tps65010_remove() calls i2c_get_clientdata(client) but the client data
is never set during initialization, so it gets a NULL pointer at best.

I guess it was never spotted because the tps65010 driver is typically
not built modular so this function is discarded.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: David Brownell <dbrownell@users.sourceforge.net>
2008-04-29 23:11:38 +02:00
Jean Delvare 1842cc2eeb i2c-sis5595: Minor cleanups in sis5595_access
* Remove commented-out code.
* Use dev_warn instead of printk.
* Remove a legacy comment.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-04-29 23:11:38 +02:00
Jean Delvare 3578a0759e i2c-piix4: Minor cleanups
* Remove a needless include.
* Remove a legacy comment in piix4_access.
* Minor optimization in piix4_access.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-04-29 23:11:37 +02:00
Jean Delvare c5d21b7fb7 i2c: Spelling fix (successful)
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-04-29 23:11:37 +02:00
Jean Delvare 85d6931cde i2c-stub: No newline in parameter description
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-04-29 23:11:37 +02:00
Kay Sievers add8eda7f2 i2c: Fix platform driver hotplug/coldplug
Since 43cc71eed1, the platform
modalias is prefixed with "platform:". Add MODULE_ALIAS() to the
hotpluggable I2C platform drivers, to allow module auto loading.

[ db: add some more drivers ]

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-04-22 22:16:49 +02:00
Magnus Damm da672773d8 i2c: New driver for the SuperH Mobile I2C bus controller
This is V5 of the SuperH Mobile I2C Controller Driver. A simple Master
only driver for the I2C block included in processors such as sh7343,
sh7722 and sh7723. Tested on a sh7722 MigoR using a rs5c732b rtc.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-04-22 22:16:49 +02:00
Adrian Bunk dec1a998bd i2c/scx200_acb: Don't use 0 as NULL pointer
Don't use 0 as NULL pointer.

Spotted by sparse.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-04-22 22:16:48 +02:00
Hans Schillstrom afc13b765e i2c-bfin-twi: Fix mismatch in add timer and delete timer
Move init_completion to just before i2c transfer.
http://blackfin.uclinux.org/gf/project/uclinux-dist/tracker/?action=TrackerItemEdit&tracker_item_id=3385

Signed-off-by: Hans Schillstrom <hans.schillstrom@shlsys.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-04-22 22:16:48 +02:00
Bryan Wu d4ce220d49 i2c-bfin-twi: Just let i2c-bfin-twi driver depends on BLACKFIN
Simply use "depends on BLACKFIN" (which is technically correct) and just
document which machines have the device.

Signed-off-by: Bryan Wu <cooloney@kernel.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-04-22 22:16:48 +02:00