Commit 40aba218 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging

* 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
  i2c: Clearly mark ACPI drivers as such
  i2c: Add driver for SMBus Control Method Interface
  i2c-pnx: Correct use of request_region/request_mem_region
  MAINTAINERS: Add maintainer for AT24 and PCA9564/PCA9665
  i2c-piix4: Add AMD SB900 SMBus device ID
  i2c/chips: Remove deprecated pcf8574 driver
  i2c/chips: Remove deprecated pca9539 driver
  i2c/chips: Remove deprecated pcf8575 driver
  gpio/pcf857x: Copy i2c_device_id from old pcf8574 driver
  i2c/scx200_acb: Provide more information on bus errors
  i2c: Provide compatibility links for i2c adapters
  i2c: Convert i2c adapters to bus devices
  i2c: Convert i2c clients to a device type
  i2c/tsl2550: Use combined SMBus transactions
  i2c-taos-evm: Switch echo off to improve performance
  i2c: Drop unused i2c_driver.id field
parents b64ada6b cfd550ed
......@@ -8,6 +8,8 @@ Supported adapters:
Datasheet: Only available via NDA from ServerWorks
* ATI IXP200, IXP300, IXP400, SB600, SB700 and SB800 southbridges
Datasheet: Not publicly available
* AMD SB900
Datasheet: Not publicly available
* Standard Microsystems (SMSC) SLC90E66 (Victory66) southbridge
Datasheet: Publicly available at the SMSC website http://www.smsc.com
......
Kernel driver pca9539
=====================
NOTE: this driver is deprecated and will be dropped soon, use
drivers/gpio/pca9539.c instead.
Supported chips:
* Philips PCA9539
Prefix: 'pca9539'
Addresses scanned: none
Datasheet:
http://www.semiconductors.philips.com/acrobat/datasheets/PCA9539_2.pdf
Author: Ben Gardner <bgardner@wabtec.com>
Description
-----------
The Philips PCA9539 is a 16 bit low power I/O device.
All 16 lines can be individually configured as an input or output.
The input sense can also be inverted.
The 16 lines are split between two bytes.
Detection
---------
The PCA9539 is difficult to detect and not commonly found in PC machines,
so you have to pass the I2C bus and address of the installed PCA9539
devices explicitly to the driver at load time via the force=... parameter.
Sysfs entries
-------------
Each is a byte that maps to the 8 I/O bits.
A '0' suffix is for bits 0-7, while '1' is for bits 8-15.
input[01] - read the current value
output[01] - sets the output value
direction[01] - direction of each bit: 1=input, 0=output
invert[01] - toggle the input bit sense
input reads the actual state of the line and is always available.
The direction defaults to input for all channels.
General Remarks
---------------
Note that each output, direction, and invert entry controls 8 lines.
You should use the read, modify, write sequence.
For example. to set output bit 0 of 1.
val=$(cat output0)
val=$(( $val | 1 ))
echo $val > output0
Kernel driver pcf8574
=====================
Supported chips:
* Philips PCF8574
Prefix: 'pcf8574'
Addresses scanned: none
Datasheet: Publicly available at the Philips Semiconductors website
http://www.semiconductors.philips.com/pip/PCF8574P.html
* Philips PCF8574A
Prefix: 'pcf8574a'
Addresses scanned: none
Datasheet: Publicly available at the Philips Semiconductors website
http://www.semiconductors.philips.com/pip/PCF8574P.html
Authors:
Frodo Looijaard <frodol@dds.nl>,
Philip Edelbrock <phil@netroedge.com>,
Dan Eaton <dan.eaton@rocketlogix.com>,
Aurelien Jarno <aurelien@aurel32.net>,
Jean Delvare <khali@linux-fr.org>,
Description
-----------
The PCF8574(A) is an 8-bit I/O expander for the I2C bus produced by Philips
Semiconductors. It is designed to provide a byte I2C interface to up to 16
separate devices (8 x PCF8574 and 8 x PCF8574A).
This device consists of a quasi-bidirectional port. Each of the eight I/Os
can be independently used as an input or output. To setup an I/O as an
input, you have to write a 1 to the corresponding output.
For more informations see the datasheet.
Accessing PCF8574(A) via /sys interface
-------------------------------------
The PCF8574(A) is plainly impossible to detect ! Stupid chip.
So, you have to pass the I2C bus and address of the installed PCF857A
and PCF8574A devices explicitly to the driver at load time via the
force=... parameter.
On detection (i.e. insmod, modprobe et al.), directories are being
created for each detected PCF8574(A):
/sys/bus/i2c/devices/<0>-<1>/
where <0> is the bus the chip was detected on (e. g. i2c-0)
and <1> the chip address ([20..27] or [38..3f]):
(example: /sys/bus/i2c/devices/1-0020/)
Inside these directories, there are two files each:
read and write (and one file with chip name).
The read file is read-only. Reading gives you the current I/O input
if the corresponding output is set as 1, otherwise the current output
value, that is to say 0.
The write file is read/write. Writing a value outputs it on the I/O
port. Reading returns the last written value. As it is not possible
to read this value from the chip, you need to write at least once to
this file before you can read back from it.
About the PCF8575 chip and the pcf8575 kernel driver
====================================================
The PCF8575 chip is produced by the following manufacturers:
* Philips NXP
http://www.nxp.com/#/pip/cb=[type=product,path=50807/41735/41850,final=PCF8575_3]|pip=[pip=PCF8575_3][0]
* Texas Instruments
http://focus.ti.com/docs/prod/folders/print/pcf8575.html
Some vendors sell small PCB's with the PCF8575 mounted on it. You can connect
such a board to a Linux host via e.g. an USB to I2C interface. Examples of
PCB boards with a PCF8575:
* SFE Breakout Board for PCF8575 I2C Expander by RobotShop
http://www.robotshop.ca/home/products/robot-parts/electronics/adapters-converters/sfe-pcf8575-i2c-expander-board.html
* Breakout Board for PCF8575 I2C Expander by Spark Fun Electronics
http://www.sparkfun.com/commerce/product_info.php?products_id=8130
Description
-----------
The PCF8575 chip is a 16-bit I/O expander for the I2C bus. Up to eight of
these chips can be connected to the same I2C bus. You can find this
chip on some custom designed hardware, but you won't find it on PC
motherboards.
The PCF8575 chip consists of a 16-bit quasi-bidirectional port and an I2C-bus
interface. Each of the sixteen I/O's can be independently used as an input or
an output. To set up an I/O pin as an input, you have to write a 1 to the
corresponding output.
For more information please see the datasheet.
Detection
---------
There is no method known to detect whether a chip on a given I2C address is
a PCF8575 or whether it is any other I2C device, so you have to pass the I2C
bus and address of the installed PCF8575 devices explicitly to the driver at
load time via the force=... parameter.
/sys interface
--------------
For each address on which a PCF8575 chip was found or forced the following
files will be created under /sys:
* /sys/bus/i2c/devices/<bus>-<address>/read
* /sys/bus/i2c/devices/<bus>-<address>/write
where bus is the I2C bus number (0, 1, ...) and address is the four-digit
hexadecimal representation of the 7-bit I2C address of the PCF8575
(0020 .. 0027).
The read file is read-only. Reading it will trigger an I2C read and will hence
report the current input state for the pins configured as inputs, and the
current output value for the pins configured as outputs.
The write file is read-write. Writing a value to it will configure all pins
as output for which the corresponding bit is zero. Reading the write file will
return the value last written, or -EAGAIN if no value has yet been written to
the write file.
On module initialization the configuration of the chip is not changed -- the
chip is left in the state it was already configured in through either power-up
or through previous I2C write actions.
......@@ -895,6 +895,13 @@ F: drivers/dma/
F: include/linux/dmaengine.h
F: include/linux/async_tx.h
AT24 EEPROM DRIVER
M: Wolfram Sang <w.sang@pengutronix.de>
L: linux-i2c@vger.kernel.org
S: Maintained
F: drivers/misc/eeprom/at24.c
F: include/linux/i2c/at24.h
ATA OVER ETHERNET (AOE) DRIVER
M: "Ed L. Cashin" <ecashin@coraid.com>
W: http://www.coraid.com/support/linux
......@@ -3964,6 +3971,15 @@ S: Maintained
F: drivers/leds/leds-pca9532.c
F: include/linux/leds-pca9532.h
PCA9564/PCA9665 I2C BUS DRIVER
M: Wolfram Sang <w.sang@pengutronix.de>
L: linux-i2c@vger.kernel.org
S: Maintained
F: drivers/i2c/algos/i2c-algo-pca.c
F: drivers/i2c/busses/i2c-pca-*
F: include/linux/i2c-algo-pca.h
F: include/linux/i2c-pca-platform.h
PCI ERROR RECOVERY
M: Linas Vepstas <linas@austin.ibm.com>
L: linux-pci@vger.kernel.org
......
......@@ -27,6 +27,7 @@
static const struct i2c_device_id pcf857x_id[] = {
{ "pcf8574", 8 },
{ "pcf8574a", 8 },
{ "pca8574", 8 },
{ "pca9670", 8 },
{ "pca9672", 8 },
......
......@@ -27,6 +27,14 @@ config I2C_BOARDINFO
boolean
default y
config I2C_COMPAT
boolean "Enable compatibility bits for old user-space"
default y
help
Say Y here if you intend to run lm-sensors 3.1.1 or older, or any
other user-space package which expects i2c adapters to be class
devices. If you don't know, say Y.
config I2C_CHARDEV
tristate "I2C device interface"
help
......
......@@ -113,7 +113,7 @@ config I2C_ISCH
will be called i2c-isch.
config I2C_PIIX4
tristate "Intel PIIX4 and compatible (ATI/Serverworks/Broadcom/SMSC)"
tristate "Intel PIIX4 and compatible (ATI/AMD/Serverworks/Broadcom/SMSC)"
depends on PCI
help
If you say yes to this option, support will be included for the Intel
......@@ -128,6 +128,7 @@ config I2C_PIIX4
ATI SB600
ATI SB700
ATI SB800
AMD SB900
Serverworks OSB4
Serverworks CSB5
Serverworks CSB6
......@@ -231,6 +232,22 @@ config I2C_VIAPRO
This driver can also be built as a module. If so, the module
will be called i2c-viapro.
if ACPI
comment "ACPI drivers"
config I2C_SCMI
tristate "SMBus Control Method Interface"
help
This driver supports the SMBus Control Method Interface. It needs the
BIOS to declare ACPI control methods as described in the SMBus Control
Method Interface specification.
To compile this driver as a module, choose M here:
the module will be called i2c-scmi.
endif # ACPI
comment "Mac SMBus host controller drivers"
depends on PPC_CHRP || PPC_PMAC
......
......@@ -2,6 +2,9 @@
# Makefile for the i2c bus drivers.
#
# ACPI drivers
obj-$(CONFIG_I2C_SCMI) += i2c-scmi.o
# PC SMBus host controller drivers
obj-$(CONFIG_I2C_ALI1535) += i2c-ali1535.o
obj-$(CONFIG_I2C_ALI1563) += i2c-ali1563.o
......
......@@ -22,6 +22,7 @@
Intel PIIX4, 440MX
Serverworks OSB4, CSB5, CSB6, HT-1000, HT-1100
ATI IXP200, IXP300, IXP400, SB600, SB700, SB800
AMD SB900
SMSC Victory66
Note: we assume there can only be one device, with one SMBus interface.
......@@ -479,6 +480,7 @@ static struct pci_device_id piix4_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP300_SMBUS) },
{ PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS) },
{ PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS) },
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_SB900_SMBUS) },
{ PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS,
PCI_DEVICE_ID_SERVERWORKS_OSB4) },
{ PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS,
......@@ -499,9 +501,10 @@ static int __devinit piix4_probe(struct pci_dev *dev,
{
int retval;
if ((dev->vendor == PCI_VENDOR_ID_ATI) &&
(dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS) &&
(dev->revision >= 0x40))
if ((dev->vendor == PCI_VENDOR_ID_ATI &&
dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
dev->revision >= 0x40) ||
dev->vendor == PCI_VENDOR_ID_AMD)
/* base address location etc changed in SB800 */
retval = piix4_setup_sb800(dev, id);
else
......
......@@ -586,7 +586,8 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter;
/* Register I/O resource */
if (!request_region(alg_data->base, I2C_PNX_REGION_SIZE, pdev->name)) {
if (!request_mem_region(alg_data->base, I2C_PNX_REGION_SIZE,
pdev->name)) {
dev_err(&pdev->dev,
"I/O region 0x%08x for I2C already in use.\n",
alg_data->base);
......@@ -650,7 +651,7 @@ out_clock:
out_unmap:
iounmap((void *)alg_data->ioaddr);
out_release:
release_region(alg_data->base, I2C_PNX_REGION_SIZE);
release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE);
out_drvdata:
platform_set_drvdata(pdev, NULL);
out:
......@@ -667,7 +668,7 @@ static int __devexit i2c_pnx_remove(struct platform_device *pdev)
i2c_del_adapter(adap);
i2c_pnx->set_clock_stop(pdev);
iounmap((void *)alg_data->ioaddr);
release_region(alg_data->base, I2C_PNX_REGION_SIZE);
release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE);
platform_set_drvdata(pdev, NULL);
return 0;
......
/*
* SMBus driver for ACPI SMBus CMI
*
* Copyright (C) 2009 Crane Cai <crane.cai@amd.com>
*
* 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 version 2.
*/
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/stddef.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/acpi.h>
#define ACPI_SMBUS_HC_CLASS "smbus"
#define ACPI_SMBUS_HC_DEVICE_NAME "cmi"
ACPI_MODULE_NAME("smbus_cmi");
struct smbus_methods_t {
char *mt_info;
char *mt_sbr;
char *mt_sbw;
};
struct acpi_smbus_cmi {
acpi_handle handle;
struct i2c_adapter adapter;
u8 cap_info:1;
u8 cap_read:1;
u8 cap_write:1;
};
static const struct smbus_methods_t smbus_methods = {
.mt_info = "_SBI",
.mt_sbr = "_SBR",
.mt_sbw = "_SBW",
};
static const struct acpi_device_id acpi_smbus_cmi_ids[] = {
{"SMBUS01", 0},
{"", 0}
};
#define ACPI_SMBUS_STATUS_OK 0x00
#define ACPI_SMBUS_STATUS_FAIL 0x07
#define ACPI_SMBUS_STATUS_DNAK 0x10
#define ACPI_SMBUS_STATUS_DERR 0x11
#define ACPI_SMBUS_STATUS_CMD_DENY 0x12
#define ACPI_SMBUS_STATUS_UNKNOWN 0x13
#define ACPI_SMBUS_STATUS_ACC_DENY 0x17
#define ACPI_SMBUS_STATUS_TIMEOUT 0x18
#define ACPI_SMBUS_STATUS_NOTSUP 0x19
#define ACPI_SMBUS_STATUS_BUSY 0x1a
#define ACPI_SMBUS_STATUS_PEC 0x1f
#define ACPI_SMBUS_PRTCL_WRITE 0x00
#define ACPI_SMBUS_PRTCL_READ 0x01
#define ACPI_SMBUS_PRTCL_QUICK 0x02
#define ACPI_SMBUS_PRTCL_BYTE 0x04
#define ACPI_SMBUS_PRTCL_BYTE_DATA 0x06
#define ACPI_SMBUS_PRTCL_WORD_DATA 0x08
#define ACPI_SMBUS_PRTCL_BLOCK_DATA 0x0a
static int
acpi_smbus_cmi_access(struct i2c_adapter *adap, u16 addr, unsigned short flags,
char read_write, u8 command, int size,
union i2c_smbus_data *data)
{
int result = 0;
struct acpi_smbus_cmi *smbus_cmi = adap->algo_data;
unsigned char protocol;
acpi_status status = 0;
struct acpi_object_list input;
union acpi_object mt_params[5];
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *obj;
union acpi_object *pkg;
char *method;
int len = 0;
dev_dbg(&adap->dev, "access size: %d %s\n", size,
(read_write) ? "READ" : "WRITE");
switch (size) {
case I2C_SMBUS_QUICK:
protocol = ACPI_SMBUS_PRTCL_QUICK;
command = 0;
if (read_write == I2C_SMBUS_WRITE) {
mt_params[3].type = ACPI_TYPE_INTEGER;
mt_params[3].integer.value = 0;
mt_params[4].type = ACPI_TYPE_INTEGER;
mt_params[4].integer.value = 0;
}
break;
case I2C_SMBUS_BYTE:
protocol = ACPI_SMBUS_PRTCL_BYTE;
if (read_write == I2C_SMBUS_WRITE) {
mt_params[3].type = ACPI_TYPE_INTEGER;
mt_params[3].integer.value = 0;
mt_params[4].type = ACPI_TYPE_INTEGER;
mt_params[4].integer.value = 0;
} else {
command = 0;
}
break;
case I2C_SMBUS_BYTE_DATA:
protocol = ACPI_SMBUS_PRTCL_BYTE_DATA;
if (read_write == I2C_SMBUS_WRITE) {
mt_params[3].type = ACPI_TYPE_INTEGER;
mt_params[3].integer.value = 1;
mt_params[4].type = ACPI_TYPE_INTEGER;
mt_params[4].integer.value = data->byte;
}
break;
case I2C_SMBUS_WORD_DATA:
protocol = ACPI_SMBUS_PRTCL_WORD_DATA;
if (read_write == I2C_SMBUS_WRITE) {
mt_params[3].type = ACPI_TYPE_INTEGER;
mt_params[3].integer.value = 2;
mt_params[4].type = ACPI_TYPE_INTEGER;
mt_params[4].integer.value = data->word;
}
break;
case I2C_SMBUS_BLOCK_DATA:
protocol = ACPI_SMBUS_PRTCL_BLOCK_DATA;
if (read_write == I2C_SMBUS_WRITE) {
len = data->block[0];
if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
return -EINVAL;
mt_params[3].type = ACPI_TYPE_INTEGER;
mt_params[3].integer.value = len;
mt_params[4].type = ACPI_TYPE_BUFFER;
mt_params[4].buffer.pointer = data->block + 1;
}
break;
default:
dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
return -EOPNOTSUPP;
}
if (read_write == I2C_SMBUS_READ) {
protocol |= ACPI_SMBUS_PRTCL_READ;
method = smbus_methods.mt_sbr;
input.count = 3;
} else {
protocol |= ACPI_SMBUS_PRTCL_WRITE;
method = smbus_methods.mt_sbw;
input.count = 5;
}
input.pointer = mt_params;
mt_params[0].type = ACPI_TYPE_INTEGER;
mt_params[0].integer.value = protocol;
mt_params[1].type = ACPI_TYPE_INTEGER;
mt_params[1].integer.value = addr;
mt_params[2].type = ACPI_TYPE_INTEGER;
mt_params[2].integer.value = command;
status = acpi_evaluate_object(smbus_cmi->handle, method, &input,
&buffer);
if (ACPI_FAILURE(status)) {
ACPI_ERROR((AE_INFO, "Evaluating %s: %i", method, status));
return -EIO;
}
pkg = buffer.pointer;
if (pkg && pkg->type == ACPI_TYPE_PACKAGE)
obj = pkg->package.elements;
else {
ACPI_ERROR((AE_INFO, "Invalid argument type"));
result = -EIO;
goto out;
}
if (obj == NULL || obj->type != ACPI_TYPE_INTEGER) {
ACPI_ERROR((AE_INFO, "Invalid argument type"));
result = -EIO;
goto out;
}
result = obj->integer.value;
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s return status: %i\n",
method, result));
switch (result) {
case ACPI_SMBUS_STATUS_OK:
result = 0;
break;
case ACPI_SMBUS_STATUS_BUSY:
result = -EBUSY;
goto out;
case ACPI_SMBUS_STATUS_TIMEOUT:
result = -ETIMEDOUT;
goto out;
case ACPI_SMBUS_STATUS_DNAK:
result = -ENXIO;
goto out;
default:
result = -EIO;
goto out;
}
if (read_write == I2C_SMBUS_WRITE || size == I2C_SMBUS_QUICK)
goto out;
obj = pkg->package.elements + 1;
if (obj == NULL || obj->type != ACPI_TYPE_INTEGER) {
ACPI_ERROR((AE_INFO, "Invalid argument type"));
result = -EIO;
goto out;
}
len = obj->integer.value;
obj = pkg->package.elements + 2;
switch (size) {
case I2C_SMBUS_BYTE:
case I2C_SMBUS_BYTE_DATA:
case I2C_SMBUS_WORD_DATA:
if (obj == NULL || obj->type != ACPI_TYPE_INTEGER) {
ACPI_ERROR((AE_INFO, "Invalid argument type"));
result = -EIO;
goto out;
}
if (len == 2)
data->word = obj->integer.value;
else
data->byte = obj->integer.value;
break;
case I2C_SMBUS_BLOCK_DATA:
if (obj == NULL || obj->type != ACPI_TYPE_BUFFER) {
ACPI_ERROR((AE_INFO, "Invalid argument type"));
result = -EIO;
goto out;
}
if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
return -EPROTO;
data->block[0] = len;
memcpy(data->block + 1, obj->buffer.pointer, len);
break;
}
out:
kfree(buffer.pointer);
dev_dbg(&adap->dev, "Transaction status: %i\n", result);
return result;
}
static u32 acpi_smbus_cmi_func(struct i2c_adapter *adapter)
{
struct acpi_smbus_cmi *smbus_cmi = adapter->algo_data;
u32 ret;
ret = smbus_cmi->cap_read | smbus_cmi->cap_write ?
I2C_FUNC_SMBUS_QUICK : 0;
ret |= smbus_cmi->cap_read ?