aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-07 17:35:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-07 17:35:17 -0400
commit1b033447bf847ba49c3816c564c9191c97456b36 (patch)
tree4b4b19649671a230a9071c8422a065766eb86a6f
parentc0703c12ef6744b6d2565ec67a15aaf25d534abd (diff)
parentc415b303a704e5c5f766fc0404093910c36cc4ab (diff)
Merge branch 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging
Pull i2c updates from Jean Delvare: "Most visible changes are the SMBus multiplexing support added to the i2c-i801 driver, as well as support for the VIA VX900." * 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging: i2c-piix4: Fix build failure i2c: Correct struct i2c_driver doc about detection i2c-i801: Let i2c-mux-gpio find the GPIO chip i2c-mux-gpio: Update documentation i2c-mux-gpio: Add support for dynamically allocated GPIO pins i2c-mux-gpio: Use devm_kzalloc instead of kzalloc i2c-i801: Support SMBus multiplexing on Asus Z8 series i2c-viapro: Add VIA VX900 device ID i2c-parport: i2c_parport_irq can be static i2c-designware: i2c_dw_xfer_msg can be static i2c/scx200_*: Replace printks with pr_<level>s i2c: Make I2C available on UML i2c: Convert struct i2c_msg initialization to C99 format i2c-smbus: Convert kzalloc to devm_kzalloc i2c-mux: Add support for device auto-detection
-rw-r--r--Documentation/i2c/busses/i2c-viapro6
-rw-r--r--Documentation/i2c/muxes/i2c-mux-gpio18
-rw-r--r--drivers/i2c/Kconfig17
-rw-r--r--drivers/i2c/busses/Kconfig18
-rw-r--r--drivers/i2c/busses/i2c-designware-core.c2
-rw-r--r--drivers/i2c/busses/i2c-i801.c185
-rw-r--r--drivers/i2c/busses/i2c-parport.c2
-rw-r--r--drivers/i2c/busses/i2c-piix4.c1
-rw-r--r--drivers/i2c/busses/i2c-viapro.c3
-rw-r--r--drivers/i2c/busses/scx200_acb.c24
-rw-r--r--drivers/i2c/busses/scx200_i2c.c15
-rw-r--r--drivers/i2c/i2c-core.c16
-rw-r--r--drivers/i2c/i2c-mux.c22
-rw-r--r--drivers/i2c/i2c-smbus.c11
-rw-r--r--drivers/i2c/muxes/i2c-mux-gpio.c56
-rw-r--r--drivers/i2c/muxes/i2c-mux-pca9541.c2
-rw-r--r--drivers/i2c/muxes/i2c-mux-pca954x.c10
-rw-r--r--drivers/i2c/muxes/i2c-mux-pinctrl.c2
-rw-r--r--include/linux/i2c-mux-gpio.h5
-rw-r--r--include/linux/i2c-mux.h1
-rw-r--r--include/linux/i2c.h2
-rw-r--r--include/linux/i2c/pca954x.h1
-rw-r--r--include/linux/pci_ids.h1
23 files changed, 347 insertions, 73 deletions
diff --git a/Documentation/i2c/busses/i2c-viapro b/Documentation/i2c/busses/i2c-viapro
index 2e758b0e9456..b88f91ae580e 100644
--- a/Documentation/i2c/busses/i2c-viapro
+++ b/Documentation/i2c/busses/i2c-viapro
@@ -20,7 +20,10 @@ Supported adapters:
20 Datasheet: available on http://linux.via.com.tw 20 Datasheet: available on http://linux.via.com.tw
21 21
22 * VIA Technologies, Inc. VX855/VX875 22 * VIA Technologies, Inc. VX855/VX875
23 Datasheet: Availability unknown 23 Datasheet: available on http://linux.via.com.tw
24
25 * VIA Technologies, Inc. VX900
26 Datasheet: available on http://linux.via.com.tw
24 27
25Authors: 28Authors:
26 Kyösti Mälkki <kmalkki@cc.hut.fi>, 29 Kyösti Mälkki <kmalkki@cc.hut.fi>,
@@ -57,6 +60,7 @@ Your lspci -n listing must show one of these :
57 device 1106:8324 (CX700) 60 device 1106:8324 (CX700)
58 device 1106:8353 (VX800/VX820) 61 device 1106:8353 (VX800/VX820)
59 device 1106:8409 (VX855/VX875) 62 device 1106:8409 (VX855/VX875)
63 device 1106:8410 (VX900)
60 64
61If none of these show up, you should look in the BIOS for settings like 65If none of these show up, you should look in the BIOS for settings like
62enable ACPI / SMBus or even USB. 66enable ACPI / SMBus or even USB.
diff --git a/Documentation/i2c/muxes/i2c-mux-gpio b/Documentation/i2c/muxes/i2c-mux-gpio
index bd9b2299b739..d4d91a53fc39 100644
--- a/Documentation/i2c/muxes/i2c-mux-gpio
+++ b/Documentation/i2c/muxes/i2c-mux-gpio
@@ -63,3 +63,21 @@ static struct platform_device myboard_i2cmux = {
63 .platform_data = &myboard_i2cmux_data, 63 .platform_data = &myboard_i2cmux_data,
64 }, 64 },
65}; 65};
66
67If you don't know the absolute GPIO pin numbers at registration time,
68you can instead provide a chip name (.chip_name) and relative GPIO pin
69numbers, and the i2c-gpio-mux driver will do the work for you,
70including deferred probing if the GPIO chip isn't immediately
71available.
72
73Device Registration
74-------------------
75
76When registering your i2c-gpio-mux device, you should pass the number
77of any GPIO pin it uses as the device ID. This guarantees that every
78instance has a different ID.
79
80Alternatively, if you don't need a stable device name, you can simply
81pass PLATFORM_DEVID_AUTO as the device ID, and the platform core will
82assign a dynamic ID to your device. If you do not know the absolute
83GPIO pin numbers at registration time, this is even the only option.
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 5a3bb3d738d8..2f8c76becc6b 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -4,7 +4,7 @@
4 4
5menuconfig I2C 5menuconfig I2C
6 tristate "I2C support" 6 tristate "I2C support"
7 depends on HAS_IOMEM 7 depends on !S390
8 select RT_MUTEXES 8 select RT_MUTEXES
9 ---help--- 9 ---help---
10 I2C (pronounce: I-squared-C) is a slow serial bus protocol used in 10 I2C (pronounce: I-squared-C) is a slow serial bus protocol used in
@@ -49,6 +49,7 @@ config I2C_CHARDEV
49 49
50config I2C_MUX 50config I2C_MUX
51 tristate "I2C bus multiplexing support" 51 tristate "I2C bus multiplexing support"
52 depends on HAS_IOMEM
52 help 53 help
53 Say Y here if you want the I2C core to support the ability to 54 Say Y here if you want the I2C core to support the ability to
54 handle multiplexed I2C bus topologies, by presenting each 55 handle multiplexed I2C bus topologies, by presenting each
@@ -86,6 +87,19 @@ config I2C_SMBUS
86source drivers/i2c/algos/Kconfig 87source drivers/i2c/algos/Kconfig
87source drivers/i2c/busses/Kconfig 88source drivers/i2c/busses/Kconfig
88 89
90config I2C_STUB
91 tristate "I2C/SMBus Test Stub"
92 depends on EXPERIMENTAL && m
93 default 'n'
94 help
95 This module may be useful to developers of SMBus client drivers,
96 especially for certain kinds of sensor chips.
97
98 If you do build this module, be sure to read the notes and warnings
99 in <file:Documentation/i2c/i2c-stub>.
100
101 If you don't know what to do here, definitely say N.
102
89config I2C_DEBUG_CORE 103config I2C_DEBUG_CORE
90 bool "I2C Core debugging messages" 104 bool "I2C Core debugging messages"
91 help 105 help
@@ -103,6 +117,7 @@ config I2C_DEBUG_ALGO
103 117
104config I2C_DEBUG_BUS 118config I2C_DEBUG_BUS
105 bool "I2C Bus debugging messages" 119 bool "I2C Bus debugging messages"
120 depends on HAS_IOMEM
106 help 121 help
107 Say Y here if you want the I2C bus drivers to produce a bunch of 122 Say Y here if you want the I2C bus drivers to produce a bunch of
108 debug messages to the system log. Select this if you are having 123 debug messages to the system log. Select this if you are having
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 42d9fdd63de0..ff01c389e2da 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -3,6 +3,7 @@
3# 3#
4 4
5menu "I2C Hardware Bus support" 5menu "I2C Hardware Bus support"
6 depends on HAS_IOMEM
6 7
7comment "PC SMBus host controller drivers" 8comment "PC SMBus host controller drivers"
8 depends on PCI 9 depends on PCI
@@ -80,6 +81,7 @@ config I2C_I801
80 tristate "Intel 82801 (ICH/PCH)" 81 tristate "Intel 82801 (ICH/PCH)"
81 depends on PCI 82 depends on PCI
82 select CHECK_SIGNATURE if X86 && DMI 83 select CHECK_SIGNATURE if X86 && DMI
84 select GPIOLIB if I2C_MUX
83 help 85 help
84 If you say yes to this option, support will be included for the Intel 86 If you say yes to this option, support will be included for the Intel
85 801 family of mainboard I2C interfaces. Specifically, the following 87 801 family of mainboard I2C interfaces. Specifically, the following
@@ -224,7 +226,7 @@ config I2C_VIA
224 will be called i2c-via. 226 will be called i2c-via.
225 227
226config I2C_VIAPRO 228config I2C_VIAPRO
227 tristate "VIA VT82C596/82C686/82xx and CX700/VX8xx" 229 tristate "VIA VT82C596/82C686/82xx and CX700/VX8xx/VX900"
228 depends on PCI 230 depends on PCI
229 help 231 help
230 If you say yes to this option, support will be included for the VIA 232 If you say yes to this option, support will be included for the VIA
@@ -240,6 +242,7 @@ config I2C_VIAPRO
240 CX700 242 CX700
241 VX800/VX820 243 VX800/VX820
242 VX855/VX875 244 VX855/VX875
245 VX900
243 246
244 This driver can also be built as a module. If so, the module 247 This driver can also be built as a module. If so, the module
245 will be called i2c-viapro. 248 will be called i2c-viapro.
@@ -849,19 +852,6 @@ config I2C_SIBYTE
849 help 852 help
850 Supports the SiByte SOC on-chip I2C interfaces (2 channels). 853 Supports the SiByte SOC on-chip I2C interfaces (2 channels).
851 854
852config I2C_STUB
853 tristate "I2C/SMBus Test Stub"
854 depends on EXPERIMENTAL && m
855 default 'n'
856 help
857 This module may be useful to developers of SMBus client drivers,
858 especially for certain kinds of sensor chips.
859
860 If you do build this module, be sure to read the notes and warnings
861 in <file:Documentation/i2c/i2c-stub>.
862
863 If you don't know what to do here, definitely say N.
864
865config SCx200_I2C 855config SCx200_I2C
866 tristate "NatSemi SCx200 I2C using GPIO pins (DEPRECATED)" 856 tristate "NatSemi SCx200 I2C using GPIO pins (DEPRECATED)"
867 depends on SCx200_GPIO 857 depends on SCx200_GPIO
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index 7b8ebbefb581..cbba7db9ad59 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -370,7 +370,7 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
370 * messages into the tx buffer. Even if the size of i2c_msg data is 370 * messages into the tx buffer. Even if the size of i2c_msg data is
371 * longer than the size of the tx buffer, it handles everything. 371 * longer than the size of the tx buffer, it handles everything.
372 */ 372 */
373void 373static void
374i2c_dw_xfer_msg(struct dw_i2c_dev *dev) 374i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
375{ 375{
376 struct i2c_msg *msgs = dev->msgs; 376 struct i2c_msg *msgs = dev->msgs;
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 33e9b0c09af2..37793156bd93 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -80,6 +80,13 @@
80#include <linux/dmi.h> 80#include <linux/dmi.h>
81#include <linux/slab.h> 81#include <linux/slab.h>
82#include <linux/wait.h> 82#include <linux/wait.h>
83#include <linux/err.h>
84
85#if defined CONFIG_I2C_MUX || defined CONFIG_I2C_MUX_MODULE
86#include <linux/gpio.h>
87#include <linux/i2c-mux-gpio.h>
88#include <linux/platform_device.h>
89#endif
83 90
84/* I801 SMBus address offsets */ 91/* I801 SMBus address offsets */
85#define SMBHSTSTS(p) (0 + (p)->smba) 92#define SMBHSTSTS(p) (0 + (p)->smba)
@@ -158,6 +165,15 @@
158#define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS 0x8c22 165#define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS 0x8c22
159#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS 0x9c22 166#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS 0x9c22
160 167
168struct i801_mux_config {
169 char *gpio_chip;
170 unsigned values[3];
171 int n_values;
172 unsigned classes[3];
173 unsigned gpios[2]; /* Relative to gpio_chip->base */
174 int n_gpios;
175};
176
161struct i801_priv { 177struct i801_priv {
162 struct i2c_adapter adapter; 178 struct i2c_adapter adapter;
163 unsigned long smba; 179 unsigned long smba;
@@ -175,6 +191,11 @@ struct i801_priv {
175 int count; 191 int count;
176 int len; 192 int len;
177 u8 *data; 193 u8 *data;
194
195#if defined CONFIG_I2C_MUX || defined CONFIG_I2C_MUX_MODULE
196 const struct i801_mux_config *mux_drvdata;
197 struct platform_device *mux_pdev;
198#endif
178}; 199};
179 200
180static struct pci_driver i801_driver; 201static struct pci_driver i801_driver;
@@ -900,6 +921,165 @@ static void __init input_apanel_init(void) {}
900static void __devinit i801_probe_optional_slaves(struct i801_priv *priv) {} 921static void __devinit i801_probe_optional_slaves(struct i801_priv *priv) {}
901#endif /* CONFIG_X86 && CONFIG_DMI */ 922#endif /* CONFIG_X86 && CONFIG_DMI */
902 923
924#if defined CONFIG_I2C_MUX || defined CONFIG_I2C_MUX_MODULE
925static struct i801_mux_config i801_mux_config_asus_z8_d12 = {
926 .gpio_chip = "gpio_ich",
927 .values = { 0x02, 0x03 },
928 .n_values = 2,
929 .classes = { I2C_CLASS_SPD, I2C_CLASS_SPD },
930 .gpios = { 52, 53 },
931 .n_gpios = 2,
932};
933
934static struct i801_mux_config i801_mux_config_asus_z8_d18 = {
935 .gpio_chip = "gpio_ich",
936 .values = { 0x02, 0x03, 0x01 },
937 .n_values = 3,
938 .classes = { I2C_CLASS_SPD, I2C_CLASS_SPD, I2C_CLASS_SPD },
939 .gpios = { 52, 53 },
940 .n_gpios = 2,
941};
942
943static struct dmi_system_id __devinitdata mux_dmi_table[] = {
944 {
945 .matches = {
946 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
947 DMI_MATCH(DMI_BOARD_NAME, "Z8NA-D6(C)"),
948 },
949 .driver_data = &i801_mux_config_asus_z8_d12,
950 },
951 {
952 .matches = {
953 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
954 DMI_MATCH(DMI_BOARD_NAME, "Z8P(N)E-D12(X)"),
955 },
956 .driver_data = &i801_mux_config_asus_z8_d12,
957 },
958 {
959 .matches = {
960 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
961 DMI_MATCH(DMI_BOARD_NAME, "Z8NH-D12"),
962 },
963 .driver_data = &i801_mux_config_asus_z8_d12,
964 },
965 {
966 .matches = {
967 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
968 DMI_MATCH(DMI_BOARD_NAME, "Z8PH-D12/IFB"),
969 },
970 .driver_data = &i801_mux_config_asus_z8_d12,
971 },
972 {
973 .matches = {
974 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
975 DMI_MATCH(DMI_BOARD_NAME, "Z8NR-D12"),
976 },
977 .driver_data = &i801_mux_config_asus_z8_d12,
978 },
979 {
980 .matches = {
981 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
982 DMI_MATCH(DMI_BOARD_NAME, "Z8P(N)H-D12"),
983 },
984 .driver_data = &i801_mux_config_asus_z8_d12,
985 },
986 {
987 .matches = {
988 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
989 DMI_MATCH(DMI_BOARD_NAME, "Z8PG-D18"),
990 },
991 .driver_data = &i801_mux_config_asus_z8_d18,
992 },
993 {
994 .matches = {
995 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
996 DMI_MATCH(DMI_BOARD_NAME, "Z8PE-D18"),
997 },
998 .driver_data = &i801_mux_config_asus_z8_d18,
999 },
1000 {
1001 .matches = {
1002 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
1003 DMI_MATCH(DMI_BOARD_NAME, "Z8PS-D12"),
1004 },
1005 .driver_data = &i801_mux_config_asus_z8_d12,
1006 },
1007 { }
1008};
1009
1010/* Setup multiplexing if needed */
1011static int __devinit i801_add_mux(struct i801_priv *priv)
1012{
1013 struct device *dev = &priv->adapter.dev;
1014 const struct i801_mux_config *mux_config;
1015 struct i2c_mux_gpio_platform_data gpio_data;
1016 int err;
1017
1018 if (!priv->mux_drvdata)
1019 return 0;
1020 mux_config = priv->mux_drvdata;
1021
1022 /* Prepare the platform data */
1023 memset(&gpio_data, 0, sizeof(struct i2c_mux_gpio_platform_data));
1024 gpio_data.parent = priv->adapter.nr;
1025 gpio_data.values = mux_config->values;
1026 gpio_data.n_values = mux_config->n_values;
1027 gpio_data.classes = mux_config->classes;
1028 gpio_data.gpio_chip = mux_config->gpio_chip;
1029 gpio_data.gpios = mux_config->gpios;
1030 gpio_data.n_gpios = mux_config->n_gpios;
1031 gpio_data.idle = I2C_MUX_GPIO_NO_IDLE;
1032
1033 /* Register the mux device */
1034 priv->mux_pdev = platform_device_register_data(dev, "i2c-mux-gpio",
1035 PLATFORM_DEVID_AUTO, &gpio_data,
1036 sizeof(struct i2c_mux_gpio_platform_data));
1037 if (IS_ERR(priv->mux_pdev)) {
1038 err = PTR_ERR(priv->mux_pdev);
1039 priv->mux_pdev = NULL;
1040 dev_err(dev, "Failed to register i2c-mux-gpio device\n");
1041 return err;
1042 }
1043
1044 return 0;
1045}
1046
1047static void __devexit i801_del_mux(struct i801_priv *priv)
1048{
1049 if (priv->mux_pdev)
1050 platform_device_unregister(priv->mux_pdev);
1051}
1052
1053static unsigned int __devinit i801_get_adapter_class(struct i801_priv *priv)
1054{
1055 const struct dmi_system_id *id;
1056 const struct i801_mux_config *mux_config;
1057 unsigned int class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
1058 int i;
1059
1060 id = dmi_first_match(mux_dmi_table);
1061 if (id) {
1062 /* Remove from branch classes from trunk */
1063 mux_config = id->driver_data;
1064 for (i = 0; i < mux_config->n_values; i++)
1065 class &= ~mux_config->classes[i];
1066
1067 /* Remember for later */
1068 priv->mux_drvdata = mux_config;
1069 }
1070
1071 return class;
1072}
1073#else
1074static inline int i801_add_mux(struct i801_priv *priv) { return 0; }
1075static inline void i801_del_mux(struct i801_priv *priv) { }
1076
1077static inline unsigned int i801_get_adapter_class(struct i801_priv *priv)
1078{
1079 return I2C_CLASS_HWMON | I2C_CLASS_SPD;
1080}
1081#endif
1082
903static int __devinit i801_probe(struct pci_dev *dev, 1083static int __devinit i801_probe(struct pci_dev *dev,
904 const struct pci_device_id *id) 1084 const struct pci_device_id *id)
905{ 1085{
@@ -913,7 +1093,7 @@ static int __devinit i801_probe(struct pci_dev *dev,
913 1093
914 i2c_set_adapdata(&priv->adapter, priv); 1094 i2c_set_adapdata(&priv->adapter, priv);
915 priv->adapter.owner = THIS_MODULE; 1095 priv->adapter.owner = THIS_MODULE;
916 priv->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 1096 priv->adapter.class = i801_get_adapter_class(priv);
917 priv->adapter.algo = &smbus_algorithm; 1097 priv->adapter.algo = &smbus_algorithm;
918 1098
919 priv->pci_dev = dev; 1099 priv->pci_dev = dev;
@@ -1033,6 +1213,8 @@ static int __devinit i801_probe(struct pci_dev *dev,
1033 } 1213 }
1034 1214
1035 i801_probe_optional_slaves(priv); 1215 i801_probe_optional_slaves(priv);
1216 /* We ignore errors - multiplexing is optional */
1217 i801_add_mux(priv);
1036 1218
1037 pci_set_drvdata(dev, priv); 1219 pci_set_drvdata(dev, priv);
1038 1220
@@ -1052,6 +1234,7 @@ static void __devexit i801_remove(struct pci_dev *dev)
1052{ 1234{
1053 struct i801_priv *priv = pci_get_drvdata(dev); 1235 struct i801_priv *priv = pci_get_drvdata(dev);
1054 1236
1237 i801_del_mux(priv);
1055 i2c_del_adapter(&priv->adapter); 1238 i2c_del_adapter(&priv->adapter);
1056 pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg); 1239 pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg);
1057 1240
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c
index 24565687ac9b..81d887869620 100644
--- a/drivers/i2c/busses/i2c-parport.c
+++ b/drivers/i2c/busses/i2c-parport.c
@@ -151,7 +151,7 @@ static const struct i2c_algo_bit_data parport_algo_data = {
151 151
152/* ----- I2c and parallel port call-back functions and structures --------- */ 152/* ----- I2c and parallel port call-back functions and structures --------- */
153 153
154void i2c_parport_irq(void *data) 154static void i2c_parport_irq(void *data)
155{ 155{
156 struct i2c_par *adapter = data; 156 struct i2c_par *adapter = data;
157 struct i2c_client *ara = adapter->ara; 157 struct i2c_client *ara = adapter->ara;
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index ef511df2c965..8bbd6ece7c41 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -37,6 +37,7 @@
37#include <linux/stddef.h> 37#include <linux/stddef.h>
38#include <linux/ioport.h> 38#include <linux/ioport.h>
39#include <linux/i2c.h> 39#include <linux/i2c.h>
40#include <linux/slab.h>
40#include <linux/init.h> 41#include <linux/init.h>
41#include <linux/dmi.h> 42#include <linux/dmi.h>
42#include <linux/acpi.h> 43#include <linux/acpi.h>
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index 333011c83d52..271c9a2b0fd7 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -401,6 +401,7 @@ found:
401 case PCI_DEVICE_ID_VIA_CX700: 401 case PCI_DEVICE_ID_VIA_CX700:
402 case PCI_DEVICE_ID_VIA_VX800: 402 case PCI_DEVICE_ID_VIA_VX800:
403 case PCI_DEVICE_ID_VIA_VX855: 403 case PCI_DEVICE_ID_VIA_VX855:
404 case PCI_DEVICE_ID_VIA_VX900:
404 case PCI_DEVICE_ID_VIA_8251: 405 case PCI_DEVICE_ID_VIA_8251:
405 case PCI_DEVICE_ID_VIA_8237: 406 case PCI_DEVICE_ID_VIA_8237:
406 case PCI_DEVICE_ID_VIA_8237A: 407 case PCI_DEVICE_ID_VIA_8237A:
@@ -470,6 +471,8 @@ static DEFINE_PCI_DEVICE_TABLE(vt596_ids) = {
470 .driver_data = SMBBA3 }, 471 .driver_data = SMBBA3 },
471 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855), 472 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855),
472 .driver_data = SMBBA3 }, 473 .driver_data = SMBBA3 },
474 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX900),
475 .driver_data = SMBBA3 },
473 { 0, } 476 { 0, }
474}; 477};
475 478
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index 2eacb7784d56..08aab57337dd 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -23,6 +23,8 @@
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24*/ 24*/
25 25
26#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
27
26#include <linux/module.h> 28#include <linux/module.h>
27#include <linux/errno.h> 29#include <linux/errno.h>
28#include <linux/kernel.h> 30#include <linux/kernel.h>
@@ -37,8 +39,6 @@
37 39
38#include <linux/scx200.h> 40#include <linux/scx200.h>
39 41
40#define NAME "scx200_acb"
41
42MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>"); 42MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>");
43MODULE_DESCRIPTION("NatSemi SCx200 ACCESS.bus Driver"); 43MODULE_DESCRIPTION("NatSemi SCx200 ACCESS.bus Driver");
44MODULE_ALIAS("platform:cs5535-smb"); 44MODULE_ALIAS("platform:cs5535-smb");
@@ -398,7 +398,7 @@ static __devinit int scx200_acb_probe(struct scx200_acb_iface *iface)
398 outb(0x70, ACBCTL2); 398 outb(0x70, ACBCTL2);
399 399
400 if (inb(ACBCTL2) != 0x70) { 400 if (inb(ACBCTL2) != 0x70) {
401 pr_debug(NAME ": ACBCTL2 readback failed\n"); 401 pr_debug("ACBCTL2 readback failed\n");
402 return -ENXIO; 402 return -ENXIO;
403 } 403 }
404 404
@@ -406,8 +406,7 @@ static __devinit int scx200_acb_probe(struct scx200_acb_iface *iface)
406 406
407 val = inb(ACBCTL1); 407 val = inb(ACBCTL1);
408 if (val) { 408 if (val) {
409 pr_debug(NAME ": disabled, but ACBCTL1=0x%02x\n", 409 pr_debug("disabled, but ACBCTL1=0x%02x\n", val);
410 val);
411 return -ENXIO; 410 return -ENXIO;
412 } 411 }
413 412
@@ -417,8 +416,8 @@ static __devinit int scx200_acb_probe(struct scx200_acb_iface *iface)
417 416
418 val = inb(ACBCTL1); 417 val = inb(ACBCTL1);
419 if ((val & ACBCTL1_NMINTE) != ACBCTL1_NMINTE) { 418 if ((val & ACBCTL1_NMINTE) != ACBCTL1_NMINTE) {
420 pr_debug(NAME ": enabled, but NMINTE won't be set, " 419 pr_debug("enabled, but NMINTE won't be set, ACBCTL1=0x%02x\n",
421 "ACBCTL1=0x%02x\n", val); 420 val);
422 return -ENXIO; 421 return -ENXIO;
423 } 422 }
424 423
@@ -433,7 +432,7 @@ static __devinit struct scx200_acb_iface *scx200_create_iface(const char *text,
433 432
434 iface = kzalloc(sizeof(*iface), GFP_KERNEL); 433 iface = kzalloc(sizeof(*iface), GFP_KERNEL);
435 if (!iface) { 434 if (!iface) {
436 printk(KERN_ERR NAME ": can't allocate memory\n"); 435 pr_err("can't allocate memory\n");
437 return NULL; 436 return NULL;
438 } 437 }
439 438
@@ -459,14 +458,14 @@ static int __devinit scx200_acb_create(struct scx200_acb_iface *iface)
459 458
460 rc = scx200_acb_probe(iface); 459 rc = scx200_acb_probe(iface);
461 if (rc) { 460 if (rc) {
462 printk(KERN_WARNING NAME ": probe failed\n"); 461 pr_warn("probe failed\n");
463 return rc; 462 return rc;
464 } 463 }
465 464
466 scx200_acb_reset(iface); 465 scx200_acb_reset(iface);
467 466
468 if (i2c_add_adapter(adapter) < 0) { 467 if (i2c_add_adapter(adapter) < 0) {
469 printk(KERN_ERR NAME ": failed to register\n"); 468 pr_err("failed to register\n");
470 return -ENODEV; 469 return -ENODEV;
471 } 470 }
472 471
@@ -493,8 +492,7 @@ static struct scx200_acb_iface * __devinit scx200_create_dev(const char *text,
493 return NULL; 492 return NULL;
494 493
495 if (!request_region(base, 8, iface->adapter.name)) { 494 if (!request_region(base, 8, iface->adapter.name)) {
496 printk(KERN_ERR NAME ": can't allocate io 0x%lx-0x%lx\n", 495 pr_err("can't allocate io 0x%lx-0x%lx\n", base, base + 8 - 1);
497 base, base + 8 - 1);
498 goto errout_free; 496 goto errout_free;
499 } 497 }
500 498
@@ -583,7 +581,7 @@ static __init void scx200_scan_isa(void)
583 581
584static int __init scx200_acb_init(void) 582static int __init scx200_acb_init(void)
585{ 583{
586 pr_debug(NAME ": NatSemi SCx200 ACCESS.bus Driver\n"); 584 pr_debug("NatSemi SCx200 ACCESS.bus Driver\n");
587 585
588 /* First scan for ISA-based devices */ 586 /* First scan for ISA-based devices */
589 scx200_scan_isa(); /* XXX: should we care about errors? */ 587 scx200_scan_isa(); /* XXX: should we care about errors? */
diff --git a/drivers/i2c/busses/scx200_i2c.c b/drivers/i2c/busses/scx200_i2c.c
index 7ee0d502ceab..ae1258b95d60 100644
--- a/drivers/i2c/busses/scx200_i2c.c
+++ b/drivers/i2c/busses/scx200_i2c.c
@@ -21,6 +21,8 @@
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*/ 22*/
23 23
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25
24#include <linux/module.h> 26#include <linux/module.h>
25#include <linux/errno.h> 27#include <linux/errno.h>
26#include <linux/kernel.h> 28#include <linux/kernel.h>
@@ -31,8 +33,6 @@
31 33
32#include <linux/scx200_gpio.h> 34#include <linux/scx200_gpio.h>
33 35
34#define NAME "scx200_i2c"
35
36MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>"); 36MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>");
37MODULE_DESCRIPTION("NatSemi SCx200 I2C Driver"); 37MODULE_DESCRIPTION("NatSemi SCx200 I2C Driver");
38MODULE_LICENSE("GPL"); 38MODULE_LICENSE("GPL");
@@ -88,17 +88,17 @@ static struct i2c_adapter scx200_i2c_ops = {
88 88
89static int scx200_i2c_init(void) 89static int scx200_i2c_init(void)
90{ 90{
91 pr_debug(NAME ": NatSemi SCx200 I2C Driver\n"); 91 pr_debug("NatSemi SCx200 I2C Driver\n");
92 92
93 if (!scx200_gpio_present()) { 93 if (!scx200_gpio_present()) {
94 printk(KERN_ERR NAME ": no SCx200 gpio pins available\n"); 94 pr_err("no SCx200 gpio pins available\n");
95 return -ENODEV; 95 return -ENODEV;
96 } 96 }
97 97
98 pr_debug(NAME ": SCL=GPIO%02u, SDA=GPIO%02u\n", scl, sda); 98 pr_debug("SCL=GPIO%02u, SDA=GPIO%02u\n", scl, sda);
99 99
100 if (scl == -1 || sda == -1 || scl == sda) { 100 if (scl == -1 || sda == -1 || scl == sda) {
101 printk(KERN_ERR NAME ": scl and sda must be specified\n"); 101 pr_err("scl and sda must be specified\n");
102 return -EINVAL; 102 return -EINVAL;
103 } 103 }
104 104
@@ -107,8 +107,7 @@ static int scx200_i2c_init(void)
107 scx200_gpio_configure(sda, ~2, 5); 107 scx200_gpio_configure(sda, ~2, 5);
108 108
109 if (i2c_bit_add_bus(&scx200_i2c_ops) < 0) { 109 if (i2c_bit_add_bus(&scx200_i2c_ops) < 0) {
110 printk(KERN_ERR NAME ": adapter %s registration failed\n", 110 pr_err("adapter %s registration failed\n", scx200_i2c_ops.name);
111 scx200_i2c_ops.name);
112 return -ENODEV; 111 return -ENODEV;
113 } 112 }
114 113
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 2421d95130d4..a7edf987a339 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1989,12 +1989,22 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
1989 unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; 1989 unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3];
1990 unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; 1990 unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2];
1991 int num = read_write == I2C_SMBUS_READ ? 2 : 1; 1991 int num = read_write == I2C_SMBUS_READ ? 2 : 1;
1992 struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 },
1993 { addr, flags | I2C_M_RD, 0, msgbuf1 }
1994 };
1995 int i; 1992 int i;
1996 u8 partial_pec = 0; 1993 u8 partial_pec = 0;
1997 int status; 1994 int status;
1995 struct i2c_msg msg[2] = {
1996 {
1997 .addr = addr,
1998 .flags = flags,
1999 .len = 1,
2000 .buf = msgbuf0,
2001 }, {
2002 .addr = addr,
2003 .flags = flags | I2C_M_RD,
2004 .len = 0,
2005 .buf = msgbuf1,
2006 },
2007 };
1998 2008
1999 msgbuf0[0] = command; 2009 msgbuf0[0] = command;
2000 switch (size) { 2010 switch (size) {
diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
index 1038c381aea5..d94e0ce78277 100644
--- a/drivers/i2c/i2c-mux.c
+++ b/drivers/i2c/i2c-mux.c
@@ -88,9 +88,23 @@ static u32 i2c_mux_functionality(struct i2c_adapter *adap)
88 return parent->algo->functionality(parent); 88 return parent->algo->functionality(parent);
89} 89}
90 90
91/* Return all parent classes, merged */
92static unsigned int i2c_mux_parent_classes(struct i2c_adapter *parent)
93{
94 unsigned int class = 0;
95
96 do {
97 class |= parent->class;
98 parent = i2c_parent_is_i2c_adapter(parent);
99 } while (parent);
100
101 return class;
102}
103
91struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent, 104struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
92 struct device *mux_dev, 105 struct device *mux_dev,
93 void *mux_priv, u32 force_nr, u32 chan_id, 106 void *mux_priv, u32 force_nr, u32 chan_id,
107 unsigned int class,
94 int (*select) (struct i2c_adapter *, 108 int (*select) (struct i2c_adapter *,
95 void *, u32), 109 void *, u32),
96 int (*deselect) (struct i2c_adapter *, 110 int (*deselect) (struct i2c_adapter *,
@@ -127,6 +141,14 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
127 priv->adap.algo_data = priv; 141 priv->adap.algo_data = priv;
128 priv->adap.dev.parent = &parent->dev; 142 priv->adap.dev.parent = &parent->dev;
129 143
144 /* Sanity check on class */
145 if (i2c_mux_parent_classes(parent) & class)
146 dev_err(&parent->dev,
147 "Segment %d behind mux can't share classes with ancestors\n",
148 chan_id);
149 else
150 priv->adap.class = class;
151
130 /* 152 /*
131 * Try to populate the mux adapter's of_node, expands to 153 * Try to populate the mux adapter's of_node, expands to
132 * nothing if !CONFIG_OF. 154 * nothing if !CONFIG_OF.
diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c
index df3e0bf31eb3..92cdd2323b03 100644
--- a/drivers/i2c/i2c-smbus.c
+++ b/drivers/i2c/i2c-smbus.c
@@ -142,7 +142,8 @@ static int smbalert_probe(struct i2c_client *ara,
142 struct i2c_adapter *adapter = ara->adapter; 142 struct i2c_adapter *adapter = ara->adapter;
143 int res; 143 int res;
144 144
145 alert = kzalloc(sizeof(struct i2c_smbus_alert), GFP_KERNEL); 145 alert = devm_kzalloc(&ara->dev, sizeof(struct i2c_smbus_alert),
146 GFP_KERNEL);
146 if (!alert) 147 if (!alert)
147 return -ENOMEM; 148 return -ENOMEM;
148 149
@@ -154,10 +155,8 @@ static int smbalert_probe(struct i2c_client *ara,
154 if (setup->irq > 0) { 155 if (setup->irq > 0) {
155 res = devm_request_irq(&ara->dev, setup->irq, smbalert_irq, 156 res = devm_request_irq(&ara->dev, setup->irq, smbalert_irq,
156 0, "smbus_alert", alert); 157 0, "smbus_alert", alert);
157 if (res) { 158 if (res)
158 kfree(alert);
159 return res; 159 return res;
160 }
161 } 160 }
162 161
163 i2c_set_clientdata(ara, alert); 162 i2c_set_clientdata(ara, alert);
@@ -167,14 +166,12 @@ static int smbalert_probe(struct i2c_client *ara,
167 return 0; 166 return 0;
168} 167}
169 168
170/* IRQ resource is managed so it is freed automatically */ 169/* IRQ and memory resources are managed so they are freed automatically */
171static int smbalert_remove(struct i2c_client *ara) 170static int smbalert_remove(struct i2c_client *ara)
172{ 171{
173 struct i2c_smbus_alert *alert = i2c_get_clientdata(ara); 172 struct i2c_smbus_alert *alert = i2c_get_clientdata(ara);
174 173
175 cancel_work_sync(&alert->alert); 174 cancel_work_sync(&alert->alert);
176
177 kfree(alert);
178 return 0; 175 return 0;
179} 176}
180 177
diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
index 68b1f8ec3436..566a6757a33d 100644
--- a/drivers/i2c/muxes/i2c-mux-gpio.c
+++ b/drivers/i2c/muxes/i2c-mux-gpio.c
@@ -21,6 +21,7 @@ struct gpiomux {
21 struct i2c_adapter *parent; 21 struct i2c_adapter *parent;
22 struct i2c_adapter **adap; /* child busses */ 22 struct i2c_adapter **adap; /* child busses */
23 struct i2c_mux_gpio_platform_data data; 23 struct i2c_mux_gpio_platform_data data;
24 unsigned gpio_base;
24}; 25};
25 26
26static void i2c_mux_gpio_set(const struct gpiomux *mux, unsigned val) 27static void i2c_mux_gpio_set(const struct gpiomux *mux, unsigned val)
@@ -28,7 +29,8 @@ static void i2c_mux_gpio_set(const struct gpiomux *mux, unsigned val)
28 int i; 29 int i;
29 30
30 for (i = 0; i < mux->data.n_gpios; i++) 31 for (i = 0; i < mux->data.n_gpios; i++)
31 gpio_set_value(mux->data.gpios[i], val & (1 << i)); 32 gpio_set_value(mux->gpio_base + mux->data.gpios[i],
33 val & (1 << i));
32} 34}
33 35
34static int i2c_mux_gpio_select(struct i2c_adapter *adap, void *data, u32 chan) 36static int i2c_mux_gpio_select(struct i2c_adapter *adap, void *data, u32 chan)
@@ -49,13 +51,19 @@ static int i2c_mux_gpio_deselect(struct i2c_adapter *adap, void *data, u32 chan)
49 return 0; 51 return 0;
50} 52}
51 53
54static int __devinit match_gpio_chip_by_label(struct gpio_chip *chip,
55 void *data)
56{
57 return !strcmp(chip->label, data);
58}
59
52static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev) 60static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev)
53{ 61{
54 struct gpiomux *mux; 62 struct gpiomux *mux;
55 struct i2c_mux_gpio_platform_data *pdata; 63 struct i2c_mux_gpio_platform_data *pdata;
56 struct i2c_adapter *parent; 64 struct i2c_adapter *parent;
57 int (*deselect) (struct i2c_adapter *, void *, u32); 65 int (*deselect) (struct i2c_adapter *, void *, u32);
58 unsigned initial_state; 66 unsigned initial_state, gpio_base;
59 int i, ret; 67 int i, ret;
60 68
61 pdata = pdev->dev.platform_data; 69 pdata = pdev->dev.platform_data;
@@ -64,6 +72,23 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev)
64 return -ENODEV; 72 return -ENODEV;
65 } 73 }
66 74
75 /*
76 * If a GPIO chip name is provided, the GPIO pin numbers provided are
77 * relative to its base GPIO number. Otherwise they are absolute.
78 */
79 if (pdata->gpio_chip) {
80 struct gpio_chip *gpio;
81
82 gpio = gpiochip_find(pdata->gpio_chip,
83 match_gpio_chip_by_label);
84 if (!gpio)
85 return -EPROBE_DEFER;
86
87 gpio_base = gpio->base;
88 } else {
89 gpio_base = 0;
90 }
91
67 parent = i2c_get_adapter(pdata->parent); 92 parent = i2c_get_adapter(pdata->parent);
68 if (!parent) { 93 if (!parent) {
69 dev_err(&pdev->dev, "Parent adapter (%d) not found\n", 94 dev_err(&pdev->dev, "Parent adapter (%d) not found\n",
@@ -71,7 +96,7 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev)
71 return -ENODEV; 96 return -ENODEV;
72 } 97 }
73 98
74 mux = kzalloc(sizeof(*mux), GFP_KERNEL); 99 mux = devm_kzalloc(&pdev->dev, sizeof(*mux), GFP_KERNEL);
75 if (!mux) { 100 if (!mux) {
76 ret = -ENOMEM; 101 ret = -ENOMEM;
77 goto alloc_failed; 102 goto alloc_failed;
@@ -79,11 +104,13 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev)
79 104
80 mux->parent = parent; 105 mux->parent = parent;
81 mux->data = *pdata; 106 mux->data = *pdata;
82 mux->adap = kzalloc(sizeof(struct i2c_adapter *) * pdata->n_values, 107 mux->gpio_base = gpio_base;
83 GFP_KERNEL); 108 mux->adap = devm_kzalloc(&pdev->dev,
109 sizeof(*mux->adap) * pdata->n_values,
110 GFP_KERNEL);
84 if (!mux->adap) { 111 if (!mux->adap) {
85 ret = -ENOMEM; 112 ret = -ENOMEM;
86 goto alloc_failed2; 113 goto alloc_failed;
87 } 114 }
88 115
89 if (pdata->idle != I2C_MUX_GPIO_NO_IDLE) { 116 if (pdata->idle != I2C_MUX_GPIO_NO_IDLE) {
@@ -95,17 +122,19 @@ static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev)
95 } 122 }
96 123
97 for (i = 0; i < pdata->n_gpios; i++) { 124 for (i = 0; i < pdata->n_gpios; i++) {
98 ret = gpio_request(pdata->gpios[i], "i2c-mux-gpio"); 125 ret = gpio_request(gpio_base + pdata->gpios[i], "i2c-mux-gpio");
99 if (ret) 126 if (ret)
100 goto err_request_gpio; 127 goto err_request_gpio;
101 gpio_direction_output(pdata->gpios[i], 128 gpio_direction_output(gpio_base + pdata->gpios[i],
102 initial_state & (1 << i)); 129 initial_state & (1 << i));
103 } 130 }
104 131
105 for (i = 0; i < pdata->n_values; i++) { 132 for (i = 0; i < pdata->n_values; i++) {
106 u32 nr = pdata->base_nr ? (pdata->base_nr + i) : 0; 133 u32 nr = pdata->base_nr ? (pdata->base_nr + i) : 0;
134 unsigned int class = pdata->classes ? pdata->classes[i] : 0;
107 135
108 mux->adap[i] = i2c_add_mux_adapter(parent, &pdev->dev, mux, nr, i, 136 mux->adap[i] = i2c_add_mux_adapter(parent, &pdev->dev, mux, nr,
137 i, class,
109 i2c_mux_gpio_select, deselect); 138 i2c_mux_gpio_select, deselect);
110 if (!mux->adap[i]) { 139 if (!mux->adap[i]) {
111 ret = -ENODEV; 140 ret = -ENODEV;
@@ -127,10 +156,7 @@ add_adapter_failed:
127 i = pdata->n_gpios; 156 i = pdata->n_gpios;
128err_request_gpio: 157err_request_gpio:
129 for (; i > 0; i--) 158 for (; i > 0; i--)
130 gpio_free(pdata->gpios[i - 1]); 159 gpio_free(gpio_base + pdata->gpios[i - 1]);
131 kfree(mux->adap);
132alloc_failed2:
133 kfree(mux);
134alloc_failed: 160alloc_failed:
135 i2c_put_adapter(parent); 161 i2c_put_adapter(parent);
136 162
@@ -146,12 +172,10 @@ static int __devexit i2c_mux_gpio_remove(struct platform_device *pdev)
146 i2c_del_mux_adapter(mux->adap[i]); 172 i2c_del_mux_adapter(mux->adap[i]);
147 173
148 for (i = 0; i < mux->data.n_gpios; i++) 174 for (i = 0; i < mux->data.n_gpios; i++)
149 gpio_free(mux->data.gpios[i]); 175 gpio_free(mux->gpio_base + mux->data.gpios[i]);
150 176
151 platform_set_drvdata(pdev, NULL); 177 platform_set_drvdata(pdev, NULL);
152 i2c_put_adapter(mux->parent); 178 i2c_put_adapter(mux->parent);
153 kfree(mux->adap);
154 kfree(mux);
155 179
156 return 0; 180 return 0;
157} 181}
diff --git a/drivers/i2c/muxes/i2c-mux-pca9541.c b/drivers/i2c/muxes/i2c-mux-pca9541.c
index f8f72f39e0b5..f3b8f9a6a89b 100644
--- a/drivers/i2c/muxes/i2c-mux-pca9541.c
+++ b/drivers/i2c/muxes/i2c-mux-pca9541.c
@@ -354,7 +354,7 @@ static int pca9541_probe(struct i2c_client *client,
354 if (pdata) 354 if (pdata)
355 force = pdata->modes[0].adap_id; 355 force = pdata->modes[0].adap_id;
356 data->mux_adap = i2c_add_mux_adapter(adap, &client->dev, client, 356 data->mux_adap = i2c_add_mux_adapter(adap, &client->dev, client,
357 force, 0, 357 force, 0, 0,
358 pca9541_select_chan, 358 pca9541_select_chan,
359 pca9541_release_chan); 359 pca9541_release_chan);
360 360
diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
index f2dfe0d8fcce..8e4387235b69 100644
--- a/drivers/i2c/muxes/i2c-mux-pca954x.c
+++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
@@ -186,7 +186,7 @@ static int pca954x_probe(struct i2c_client *client,
186{ 186{
187 struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); 187 struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent);
188 struct pca954x_platform_data *pdata = client->dev.platform_data; 188 struct pca954x_platform_data *pdata = client->dev.platform_data;
189 int num, force; 189 int num, force, class;
190 struct pca954x *data; 190 struct pca954x *data;
191 int ret = -ENODEV; 191 int ret = -ENODEV;
192 192
@@ -216,18 +216,20 @@ static int pca954x_probe(struct i2c_client *client,
216 /* Now create an adapter for each channel */ 216 /* Now create an adapter for each channel */
217 for (num = 0; num < chips[data->type].nchans; num++) { 217 for (num = 0; num < chips[data->type].nchans; num++) {
218 force = 0; /* dynamic adap number */ 218 force = 0; /* dynamic adap number */
219 class = 0; /* no class by default */
219 if (pdata) { 220 if (pdata) {
220 if (num < pdata->num_modes) 221 if (num < pdata->num_modes) {
221 /* force static number */ 222 /* force static number */
222 force = pdata->modes[num].adap_id; 223 force = pdata->modes[num].adap_id;
223 else 224 class = pdata->modes[num].class;
225 } else
224 /* discard unconfigured channels */ 226 /* discard unconfigured channels */
225 break; 227 break;
226 } 228 }
227 229
228 data->virt_adaps[num] = 230 data->virt_adaps[num] =
229 i2c_add_mux_adapter(adap, &client->dev, client, 231 i2c_add_mux_adapter(adap, &client->dev, client,
230 force, num, pca954x_select_chan, 232 force, num, class, pca954x_select_chan,
231 (pdata && pdata->modes[num].deselect_on_exit) 233 (pdata && pdata->modes[num].deselect_on_exit)
232 ? pca954x_deselect_mux : NULL); 234 ? pca954x_deselect_mux : NULL);
233 235
diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c b/drivers/i2c/muxes/i2c-mux-pinctrl.c
index 46a669763476..5f097f309b9f 100644
--- a/drivers/i2c/muxes/i2c-mux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c
@@ -221,7 +221,7 @@ static int __devinit i2c_mux_pinctrl_probe(struct platform_device *pdev)
221 (mux->pdata->base_bus_num + i) : 0; 221 (mux->pdata->base_bus_num + i) : 0;
222 222
223 mux->busses[i] = i2c_add_mux_adapter(mux->parent, &pdev->dev, 223 mux->busses[i] = i2c_add_mux_adapter(mux->parent, &pdev->dev,
224 mux, bus, i, 224 mux, bus, i, 0,
225 i2c_mux_pinctrl_select, 225 i2c_mux_pinctrl_select,
226 deselect); 226 deselect);
227 if (!mux->busses[i]) { 227 if (!mux->busses[i]) {
diff --git a/include/linux/i2c-mux-gpio.h b/include/linux/i2c-mux-gpio.h
index a36343a37ebc..4406108201fe 100644
--- a/include/linux/i2c-mux-gpio.h
+++ b/include/linux/i2c-mux-gpio.h
@@ -21,6 +21,9 @@
21 * @values: Array of bitmasks of GPIO settings (low/high) for each 21 * @values: Array of bitmasks of GPIO settings (low/high) for each
22 * position 22 * position
23 * @n_values: Number of multiplexer positions (busses to instantiate) 23 * @n_values: Number of multiplexer positions (busses to instantiate)
24 * @classes: Optional I2C auto-detection classes
25 * @gpio_chip: Optional GPIO chip name; if set, GPIO pin numbers are given
26 * relative to the base GPIO number of that chip
24 * @gpios: Array of GPIO numbers used to control MUX 27 * @gpios: Array of GPIO numbers used to control MUX
25 * @n_gpios: Number of GPIOs used to control MUX 28 * @n_gpios: Number of GPIOs used to control MUX
26 * @idle: Bitmask to write to MUX when idle or GPIO_I2CMUX_NO_IDLE if not used 29 * @idle: Bitmask to write to MUX when idle or GPIO_I2CMUX_NO_IDLE if not used
@@ -30,6 +33,8 @@ struct i2c_mux_gpio_platform_data {
30 int base_nr; 33 int base_nr;
31 const unsigned *values; 34 const unsigned *values;
32 int n_values; 35 int n_values;
36 const unsigned *classes;
37 char *gpio_chip;
33 const unsigned *gpios; 38 const unsigned *gpios;
34 int n_gpios; 39 int n_gpios;
35 unsigned idle; 40 unsigned idle;
diff --git a/include/linux/i2c-mux.h b/include/linux/i2c-mux.h
index c79083830014..40cb05a97b46 100644
--- a/include/linux/i2c-mux.h
+++ b/include/linux/i2c-mux.h
@@ -36,6 +36,7 @@
36struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent, 36struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
37 struct device *mux_dev, 37 struct device *mux_dev,
38 void *mux_priv, u32 force_nr, u32 chan_id, 38 void *mux_priv, u32 force_nr, u32 chan_id,
39 unsigned int class,
39 int (*select) (struct i2c_adapter *, 40 int (*select) (struct i2c_adapter *,
40 void *mux_dev, u32 chan_id), 41 void *mux_dev, u32 chan_id),
41 int (*deselect) (struct i2c_adapter *, 42 int (*deselect) (struct i2c_adapter *,
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 5970266930a2..94aed0c85bb0 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -144,7 +144,7 @@ extern s32 i2c_smbus_write_i2c_block_data(const struct i2c_client *client,
144 * The driver.owner field should be set to the module owner of this driver. 144 * The driver.owner field should be set to the module owner of this driver.
145 * The driver.name field should be set to the name of this driver. 145 * The driver.name field should be set to the name of this driver.
146 * 146 *
147 * For automatic device detection, both @detect and @address_data must 147 * For automatic device detection, both @detect and @address_list must
148 * be defined. @class should also be set, otherwise only devices forced 148 * be defined. @class should also be set, otherwise only devices forced
149 * with module parameters will be created. The detect function must 149 * with module parameters will be created. The detect function must
150 * fill at least the name field of the i2c_board_info structure it is 150 * fill at least the name field of the i2c_board_info structure it is
diff --git a/include/linux/i2c/pca954x.h b/include/linux/i2c/pca954x.h
index 28f1f8d5ab1f..1712677d5904 100644
--- a/include/linux/i2c/pca954x.h
+++ b/include/linux/i2c/pca954x.h
@@ -36,6 +36,7 @@
36struct pca954x_platform_mode { 36struct pca954x_platform_mode {
37 int adap_id; 37 int adap_id;
38 unsigned int deselect_on_exit:1; 38 unsigned int deselect_on_exit:1;
39 unsigned int class;
39}; 40};
40 41
41/* Per mux/switch data, used with i2c_register_board_info */ 42/* Per mux/switch data, used with i2c_register_board_info */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 33880f6f4e51..9d36b829533a 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1427,6 +1427,7 @@
1427#define PCI_DEVICE_ID_VIA_CX700_IDE 0x0581 1427#define PCI_DEVICE_ID_VIA_CX700_IDE 0x0581
1428#define PCI_DEVICE_ID_VIA_VX800 0x8353 1428#define PCI_DEVICE_ID_VIA_VX800 0x8353
1429#define PCI_DEVICE_ID_VIA_VX855 0x8409 1429#define PCI_DEVICE_ID_VIA_VX855 0x8409
1430#define PCI_DEVICE_ID_VIA_VX900 0x8410
1430#define PCI_DEVICE_ID_VIA_8371_1 0x8391 1431#define PCI_DEVICE_ID_VIA_8371_1 0x8391
1431#define PCI_DEVICE_ID_VIA_82C598_1 0x8598 1432#define PCI_DEVICE_ID_VIA_82C598_1 0x8598
1432#define PCI_DEVICE_ID_VIA_838X_1 0xB188 1433#define PCI_DEVICE_ID_VIA_838X_1 0xB188