Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'i2c-embedded/for-next' of git://git.pengutronix.de/git/wsa/linux

Pull i2c-embedded changes from Wolfram Sang:
"Major changes:

- lots of devicetree additions for existing drivers. I tried hard to
make sure the bindings are proper. In more complicated cases, I
requested acks from people having more experience with them than
me. That took a bit of extra time and also some time went into
discussions with developers about what bindings are and what not.
I have the feeling that the workflow with bindings should be
improved to scale better. I will spend some more thought on
this...

- i2c-muxes are succesfully used meanwhile, so we dropped
EXPERIMENTAL for them and renamed the drivers to a standard pattern
to match the rest of the subsystem. They can also be used with
devicetree now.

- ixp2000 was removed since the whole platform goes away.

- cleanups (strlcpy instead of strcpy, NULL instead of 0)

- The rest is typical driver fixes I assume.

All patches have been in linux-next at least since v3.4-rc6."

Fixed up trivial conflict in arch/arm/mach-lpc32xx/common.c due to the
same patch already having come in through the arm/soc trees, with
additional patches on top of it.

* 'i2c-embedded/for-next' of git://git.pengutronix.de/git/wsa/linux: (35 commits)
i2c: davinci: Free requested IRQ in remove
i2c: ocores: register OF i2c devices
i2c: tegra: notify transfer-complete after clearing status.
I2C: xiic: Add OF binding support
i2c: Rename last mux driver to standard pattern
i2c: tegra: fix 10bit address configuration
i2c: muxes: rename first set of drivers to a standard pattern
of/i2c: implement of_find_i2c_adapter_by_node
i2c: implement i2c_verify_adapter
i2c-s3c2410: Add HDMIPHY quirk for S3C2440
i2c-s3c2410: Rework device type handling
i2c: muxes are not EXPERIMENTAL anymore
i2c/of: Automatically populate i2c mux busses from device tree data.
i2c: Add a struct device * parameter to i2c_add_mux_adapter()
of/i2c: call i2c_verify_client from of_find_i2c_device_by_node
i2c: designware: Add clk_{un}prepare() support
i2c: designware: add PM support
i2c: ixp2000: remove driver
i2c: pnx: add device tree support
i2c: imx: don't use strcpy but strlcpy
...

+485 -500
+60
Documentation/devicetree/bindings/i2c/mux.txt
··· 1 + Common i2c bus multiplexer/switch properties. 2 + 3 + An i2c bus multiplexer/switch will have several child busses that are 4 + numbered uniquely in a device dependent manner. The nodes for an i2c bus 5 + multiplexer/switch will have one child node for each child 6 + bus. 7 + 8 + Required properties: 9 + - #address-cells = <1>; 10 + - #size-cells = <0>; 11 + 12 + Required properties for child nodes: 13 + - #address-cells = <1>; 14 + - #size-cells = <0>; 15 + - reg : The sub-bus number. 16 + 17 + Optional properties for child nodes: 18 + - Other properties specific to the multiplexer/switch hardware. 19 + - Child nodes conforming to i2c bus binding 20 + 21 + 22 + Example : 23 + 24 + /* 25 + An NXP pca9548 8 channel I2C multiplexer at address 0x70 26 + with two NXP pca8574 GPIO expanders attached, one each to 27 + ports 3 and 4. 28 + */ 29 + 30 + mux@70 { 31 + compatible = "nxp,pca9548"; 32 + reg = <0x70>; 33 + #address-cells = <1>; 34 + #size-cells = <0>; 35 + 36 + i2c@3 { 37 + #address-cells = <1>; 38 + #size-cells = <0>; 39 + reg = <3>; 40 + 41 + gpio1: gpio@38 { 42 + compatible = "nxp,pca8574"; 43 + reg = <0x38>; 44 + #gpio-cells = <2>; 45 + gpio-controller; 46 + }; 47 + }; 48 + i2c@4 { 49 + #address-cells = <1>; 50 + #size-cells = <0>; 51 + reg = <4>; 52 + 53 + gpio2: gpio@38 { 54 + compatible = "nxp,pca8574"; 55 + reg = <0x38>; 56 + #gpio-cells = <2>; 57 + gpio-controller; 58 + }; 59 + }; 60 + };
+6 -2
Documentation/devicetree/bindings/i2c/samsung-i2c.txt
··· 6 6 - compatible: value should be either of the following. 7 7 (a) "samsung, s3c2410-i2c", for i2c compatible with s3c2410 i2c. 8 8 (b) "samsung, s3c2440-i2c", for i2c compatible with s3c2440 i2c. 9 + (c) "samsung, s3c2440-hdmiphy-i2c", for s3c2440-like i2c used 10 + inside HDMIPHY block found on several samsung SoCs 9 11 - reg: physical base address of the controller and length of memory mapped 10 12 region. 11 13 - interrupts: interrupt number to the cpu. 12 14 - samsung,i2c-sda-delay: Delay (in ns) applied to data line (SDA) edges. 13 - - gpios: The order of the gpios should be the following: <SDA, SCL>. 14 - The gpio specifier depends on the gpio controller. 15 15 16 16 Optional properties: 17 + - gpios: The order of the gpios should be the following: <SDA, SCL>. 18 + The gpio specifier depends on the gpio controller. Required in all 19 + cases except for "samsung,s3c2440-hdmiphy-i2c" whose input/output 20 + lines are permanently wired to the respective client 17 21 - samsung,i2c-slave-addr: Slave address in multi-master enviroment. If not 18 22 specified, default value is 0. 19 23 - samsung,i2c-max-bus-freq: Desired frequency in Hz of the bus. If not
+22
Documentation/devicetree/bindings/i2c/xiic.txt
··· 1 + Xilinx IIC controller: 2 + 3 + Required properties: 4 + - compatible : Must be "xlnx,xps-iic-2.00.a" 5 + - reg : IIC register location and length 6 + - interrupts : IIC controller unterrupt 7 + - #address-cells = <1> 8 + - #size-cells = <0> 9 + 10 + Optional properties: 11 + - Child nodes conforming to i2c bus binding 12 + 13 + Example: 14 + 15 + axi_iic_0: i2c@40800000 { 16 + compatible = "xlnx,xps-iic-2.00.a"; 17 + interrupts = < 1 2 >; 18 + reg = < 0x40800000 0x10000 >; 19 + 20 + #size-cells = <0>; 21 + #address-cells = <1>; 22 + };
+6 -6
Documentation/i2c/muxes/gpio-i2cmux Documentation/i2c/muxes/i2c-mux-gpio
··· 1 - Kernel driver gpio-i2cmux 1 + Kernel driver i2c-gpio-mux 2 2 3 3 Author: Peter Korsgaard <peter.korsgaard@barco.com> 4 4 5 5 Description 6 6 ----------- 7 7 8 - gpio-i2cmux is an i2c mux driver providing access to I2C bus segments 8 + i2c-gpio-mux is an i2c mux driver providing access to I2C bus segments 9 9 from a master I2C bus and a hardware MUX controlled through GPIO pins. 10 10 11 11 E.G.: ··· 26 26 Usage 27 27 ----- 28 28 29 - gpio-i2cmux uses the platform bus, so you need to provide a struct 29 + i2c-gpio-mux uses the platform bus, so you need to provide a struct 30 30 platform_device with the platform_data pointing to a struct 31 31 gpio_i2cmux_platform_data with the I2C adapter number of the master 32 32 bus, the number of bus segments to create and the GPIO pins used 33 - to control it. See include/linux/gpio-i2cmux.h for details. 33 + to control it. See include/linux/i2c-gpio-mux.h for details. 34 34 35 35 E.G. something like this for a MUX providing 4 bus segments 36 36 controlled through 3 GPIO pins: 37 37 38 - #include <linux/gpio-i2cmux.h> 38 + #include <linux/i2c-gpio-mux.h> 39 39 #include <linux/platform_device.h> 40 40 41 41 static const unsigned myboard_gpiomux_gpios[] = { ··· 57 57 }; 58 58 59 59 static struct platform_device myboard_i2cmux = { 60 - .name = "gpio-i2cmux", 60 + .name = "i2c-gpio-mux", 61 61 .id = 0, 62 62 .dev = { 63 63 .platform_data = &myboard_i2cmux_data,
+4 -4
MAINTAINERS
··· 2988 2988 M: Peter Korsgaard <peter.korsgaard@barco.com> 2989 2989 L: linux-i2c@vger.kernel.org 2990 2990 S: Supported 2991 - F: drivers/i2c/muxes/gpio-i2cmux.c 2992 - F: include/linux/gpio-i2cmux.h 2993 - F: Documentation/i2c/muxes/gpio-i2cmux 2991 + F: drivers/i2c/muxes/i2c-mux-gpio.c 2992 + F: include/linux/i2c-mux-gpio.h 2993 + F: Documentation/i2c/muxes/i2c-mux-gpio 2994 2994 2995 2995 GENERIC HDLC (WAN) DRIVERS 2996 2996 M: Krzysztof Halasa <khc@pm.waw.pl> ··· 5148 5148 M: Guenter Roeck <guenter.roeck@ericsson.com> 5149 5149 L: linux-i2c@vger.kernel.org 5150 5150 S: Maintained 5151 - F: drivers/i2c/muxes/pca9541.c 5151 + F: drivers/i2c/muxes/i2c-mux-pca9541.c 5152 5152 5153 5153 PCA9564/PCA9665 I2C BUS DRIVER 5154 5154 M: Wolfram Sang <w.sang@pengutronix.de>
-1
drivers/i2c/Kconfig
··· 49 49 50 50 config I2C_MUX 51 51 tristate "I2C bus multiplexing support" 52 - depends on EXPERIMENTAL 53 52 help 54 53 Say Y here if you want the I2C core to support the ability to 55 54 handle multiplexed I2C bus topologies, by presenting each
-14
drivers/i2c/busses/Kconfig
··· 445 445 This driver can also be built as a module. If so, the module 446 446 will be called i2c-iop3xx. 447 447 448 - config I2C_IXP2000 449 - tristate "IXP2000 GPIO-Based I2C Interface (DEPRECATED)" 450 - depends on ARCH_IXP2000 451 - select I2C_ALGOBIT 452 - help 453 - Say Y here if you have an Intel IXP2000 (2400, 2800, 2850) based 454 - system and are using GPIO lines for an I2C bus. 455 - 456 - This support is also available as a module. If so, the module 457 - will be called i2c-ixp2000. 458 - 459 - This driver is deprecated and will be dropped soon. Use i2c-gpio 460 - instead. 461 - 462 448 config I2C_MPC 463 449 tristate "MPC107/824x/85xx/512x/52xx/83xx/86xx" 464 450 depends on PPC
-1
drivers/i2c/busses/Makefile
··· 44 44 obj-$(CONFIG_I2C_IMX) += i2c-imx.o 45 45 obj-$(CONFIG_I2C_INTEL_MID) += i2c-intel-mid.o 46 46 obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o 47 - obj-$(CONFIG_I2C_IXP2000) += i2c-ixp2000.o 48 47 obj-$(CONFIG_I2C_MPC) += i2c-mpc.o 49 48 obj-$(CONFIG_I2C_MV64XXX) += i2c-mv64xxx.o 50 49 obj-$(CONFIG_I2C_MXS) += i2c-mxs.o
+1 -1
drivers/i2c/busses/i2c-davinci.c
··· 755 755 dev->clk = NULL; 756 756 757 757 davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, 0); 758 - free_irq(IRQ_I2C, dev); 758 + free_irq(dev->irq, dev); 759 759 iounmap(dev->base); 760 760 kfree(dev); 761 761
+21 -10
drivers/i2c/busses/i2c-designware-core.c
··· 164 164 165 165 u32 dw_readl(struct dw_i2c_dev *dev, int offset) 166 166 { 167 - u32 value = readl(dev->base + offset); 167 + u32 value; 168 168 169 - if (dev->swab) 169 + if (dev->accessor_flags & ACCESS_16BIT) 170 + value = readw(dev->base + offset) | 171 + (readw(dev->base + offset + 2) << 16); 172 + else 173 + value = readl(dev->base + offset); 174 + 175 + if (dev->accessor_flags & ACCESS_SWAP) 170 176 return swab32(value); 171 177 else 172 178 return value; ··· 180 174 181 175 void dw_writel(struct dw_i2c_dev *dev, u32 b, int offset) 182 176 { 183 - if (dev->swab) 177 + if (dev->accessor_flags & ACCESS_SWAP) 184 178 b = swab32(b); 185 179 186 - writel(b, dev->base + offset); 180 + if (dev->accessor_flags & ACCESS_16BIT) { 181 + writew((u16)b, dev->base + offset); 182 + writew((u16)(b >> 16), dev->base + offset + 2); 183 + } else { 184 + writel(b, dev->base + offset); 185 + } 187 186 } 188 187 189 188 static u32 ··· 262 251 263 252 input_clock_khz = dev->get_clk_rate_khz(dev); 264 253 265 - /* Configure register endianess access */ 266 254 reg = dw_readl(dev, DW_IC_COMP_TYPE); 267 255 if (reg == ___constant_swab32(DW_IC_COMP_TYPE_VALUE)) { 268 - dev->swab = 1; 269 - reg = DW_IC_COMP_TYPE_VALUE; 270 - } 271 - 272 - if (reg != DW_IC_COMP_TYPE_VALUE) { 256 + /* Configure register endianess access */ 257 + dev->accessor_flags |= ACCESS_SWAP; 258 + } else if (reg == (DW_IC_COMP_TYPE_VALUE & 0x0000ffff)) { 259 + /* Configure register access mode 16bit */ 260 + dev->accessor_flags |= ACCESS_16BIT; 261 + } else if (reg != DW_IC_COMP_TYPE_VALUE) { 273 262 dev_err(dev->dev, "Unknown Synopsys component type: " 274 263 "0x%08x\n", reg); 275 264 return -ENODEV;
+4 -1
drivers/i2c/busses/i2c-designware-core.h
··· 82 82 unsigned int status; 83 83 u32 abort_source; 84 84 int irq; 85 - int swab; 85 + u32 accessor_flags; 86 86 struct i2c_adapter adapter; 87 87 u32 functionality; 88 88 u32 master_cfg; 89 89 unsigned int tx_fifo_depth; 90 90 unsigned int rx_fifo_depth; 91 91 }; 92 + 93 + #define ACCESS_SWAP 0x00000001 94 + #define ACCESS_16BIT 0x00000002 92 95 93 96 extern u32 dw_readl(struct dw_i2c_dev *dev, int offset); 94 97 extern void dw_writel(struct dw_i2c_dev *dev, u32 b, int offset);
+30 -3
drivers/i2c/busses/i2c-designware-platdrv.c
··· 36 36 #include <linux/interrupt.h> 37 37 #include <linux/of_i2c.h> 38 38 #include <linux/platform_device.h> 39 + #include <linux/pm.h> 39 40 #include <linux/io.h> 40 41 #include <linux/slab.h> 41 42 #include "i2c-designware-core.h" ··· 96 95 r = -ENODEV; 97 96 goto err_free_mem; 98 97 } 99 - clk_enable(dev->clk); 98 + clk_prepare_enable(dev->clk); 100 99 101 100 dev->functionality = 102 101 I2C_FUNC_I2C | ··· 156 155 err_iounmap: 157 156 iounmap(dev->base); 158 157 err_unuse_clocks: 159 - clk_disable(dev->clk); 158 + clk_disable_unprepare(dev->clk); 160 159 clk_put(dev->clk); 161 160 dev->clk = NULL; 162 161 err_free_mem: ··· 178 177 i2c_del_adapter(&dev->adapter); 179 178 put_device(&pdev->dev); 180 179 181 - clk_disable(dev->clk); 180 + clk_disable_unprepare(dev->clk); 182 181 clk_put(dev->clk); 183 182 dev->clk = NULL; 184 183 ··· 199 198 MODULE_DEVICE_TABLE(of, dw_i2c_of_match); 200 199 #endif 201 200 201 + #ifdef CONFIG_PM 202 + static int dw_i2c_suspend(struct device *dev) 203 + { 204 + struct platform_device *pdev = to_platform_device(dev); 205 + struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev); 206 + 207 + clk_disable_unprepare(i_dev->clk); 208 + 209 + return 0; 210 + } 211 + 212 + static int dw_i2c_resume(struct device *dev) 213 + { 214 + struct platform_device *pdev = to_platform_device(dev); 215 + struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev); 216 + 217 + clk_prepare_enable(i_dev->clk); 218 + i2c_dw_init(i_dev); 219 + 220 + return 0; 221 + } 222 + #endif 223 + 224 + static SIMPLE_DEV_PM_OPS(dw_i2c_dev_pm_ops, dw_i2c_suspend, dw_i2c_resume); 225 + 202 226 /* work with hotplug and coldplug */ 203 227 MODULE_ALIAS("platform:i2c_designware"); 204 228 ··· 233 207 .name = "i2c_designware", 234 208 .owner = THIS_MODULE, 235 209 .of_match_table = of_match_ptr(dw_i2c_of_match), 210 + .pm = &dw_i2c_dev_pm_ops, 236 211 }, 237 212 }; 238 213
+75 -171
drivers/i2c/busses/i2c-eg20t.c
··· 263 263 init_waitqueue_head(&pch_event); 264 264 } 265 265 266 - static inline bool ktime_lt(const ktime_t cmp1, const ktime_t cmp2) 267 - { 268 - return cmp1.tv64 < cmp2.tv64; 269 - } 270 - 271 266 /** 272 267 * pch_i2c_wait_for_bus_idle() - check the status of bus. 273 268 * @adap: Pointer to struct i2c_algo_pch_data. ··· 312 317 } 313 318 314 319 /** 315 - * pch_i2c_wait_for_xfer_complete() - initiates a wait for the tx complete event 316 - * @adap: Pointer to struct i2c_algo_pch_data. 317 - */ 318 - static s32 pch_i2c_wait_for_xfer_complete(struct i2c_algo_pch_data *adap) 319 - { 320 - long ret; 321 - ret = wait_event_timeout(pch_event, 322 - (adap->pch_event_flag != 0), msecs_to_jiffies(1000)); 323 - 324 - if (ret == 0) { 325 - pch_err(adap, "timeout: %x\n", adap->pch_event_flag); 326 - adap->pch_event_flag = 0; 327 - return -ETIMEDOUT; 328 - } 329 - 330 - if (adap->pch_event_flag & I2C_ERROR_MASK) { 331 - pch_err(adap, "error bits set: %x\n", adap->pch_event_flag); 332 - adap->pch_event_flag = 0; 333 - return -EIO; 334 - } 335 - 336 - adap->pch_event_flag = 0; 337 - 338 - return 0; 339 - } 340 - 341 - /** 342 320 * pch_i2c_getack() - to confirm ACK/NACK 343 321 * @adap: Pointer to struct i2c_algo_pch_data. 344 322 */ ··· 339 371 pch_dbg(adap, "I2CCTL = %x\n", ioread32(p + PCH_I2CCTL)); 340 372 /* clear the start bit */ 341 373 pch_clrbit(adap->pch_base_address, PCH_I2CCTL, PCH_START); 374 + } 375 + 376 + static int pch_i2c_wait_for_check_xfer(struct i2c_algo_pch_data *adap) 377 + { 378 + long ret; 379 + 380 + ret = wait_event_timeout(pch_event, 381 + (adap->pch_event_flag != 0), msecs_to_jiffies(1000)); 382 + if (!ret) { 383 + pch_err(adap, "%s:wait-event timeout\n", __func__); 384 + adap->pch_event_flag = 0; 385 + pch_i2c_stop(adap); 386 + pch_i2c_init(adap); 387 + return -ETIMEDOUT; 388 + } 389 + 390 + if (adap->pch_event_flag & I2C_ERROR_MASK) { 391 + pch_err(adap, "Lost Arbitration\n"); 392 + adap->pch_event_flag = 0; 393 + pch_clrbit(adap->pch_base_address, PCH_I2CSR, I2CMAL_BIT); 394 + pch_clrbit(adap->pch_base_address, PCH_I2CSR, I2CMIF_BIT); 395 + pch_i2c_init(adap); 396 + return -EAGAIN; 397 + } 398 + 399 + adap->pch_event_flag = 0; 400 + 401 + if (pch_i2c_getack(adap)) { 402 + pch_dbg(adap, "Receive NACK for slave address" 403 + "setting\n"); 404 + return -EIO; 405 + } 406 + 407 + return 0; 342 408 } 343 409 344 410 /** ··· 429 427 if (first) 430 428 pch_i2c_start(adap); 431 429 432 - rtn = pch_i2c_wait_for_xfer_complete(adap); 433 - if (rtn == 0) { 434 - if (pch_i2c_getack(adap)) { 435 - pch_dbg(adap, "Receive NACK for slave address" 436 - "setting\n"); 437 - return -EIO; 438 - } 439 - addr_8_lsb = (addr & I2C_ADDR_MSK); 440 - iowrite32(addr_8_lsb, p + PCH_I2CDR); 441 - } else if (rtn == -EIO) { /* Arbitration Lost */ 442 - pch_err(adap, "Lost Arbitration\n"); 443 - pch_clrbit(adap->pch_base_address, PCH_I2CSR, 444 - I2CMAL_BIT); 445 - pch_clrbit(adap->pch_base_address, PCH_I2CSR, 446 - I2CMIF_BIT); 447 - pch_i2c_init(adap); 448 - return -EAGAIN; 449 - } else { /* wait-event timeout */ 450 - pch_i2c_stop(adap); 451 - return -ETIME; 452 - } 430 + rtn = pch_i2c_wait_for_check_xfer(adap); 431 + if (rtn) 432 + return rtn; 433 + 434 + addr_8_lsb = (addr & I2C_ADDR_MSK); 435 + iowrite32(addr_8_lsb, p + PCH_I2CDR); 453 436 } else { 454 437 /* set 7 bit slave address and R/W bit as 0 */ 455 438 iowrite32(addr << 1, p + PCH_I2CDR); ··· 442 455 pch_i2c_start(adap); 443 456 } 444 457 445 - rtn = pch_i2c_wait_for_xfer_complete(adap); 446 - if (rtn == 0) { 447 - if (pch_i2c_getack(adap)) { 448 - pch_dbg(adap, "Receive NACK for slave address" 449 - "setting\n"); 450 - return -EIO; 451 - } 452 - } else if (rtn == -EIO) { /* Arbitration Lost */ 453 - pch_err(adap, "Lost Arbitration\n"); 454 - pch_clrbit(adap->pch_base_address, PCH_I2CSR, I2CMAL_BIT); 455 - pch_clrbit(adap->pch_base_address, PCH_I2CSR, I2CMIF_BIT); 456 - pch_i2c_init(adap); 457 - return -EAGAIN; 458 - } else { /* wait-event timeout */ 459 - pch_i2c_stop(adap); 460 - return -ETIME; 461 - } 458 + rtn = pch_i2c_wait_for_check_xfer(adap); 459 + if (rtn) 460 + return rtn; 462 461 463 462 for (wrcount = 0; wrcount < length; ++wrcount) { 464 463 /* write buffer value to I2C data register */ 465 464 iowrite32(buf[wrcount], p + PCH_I2CDR); 466 465 pch_dbg(adap, "writing %x to Data register\n", buf[wrcount]); 467 466 468 - rtn = pch_i2c_wait_for_xfer_complete(adap); 469 - if (rtn == 0) { 470 - if (pch_i2c_getack(adap)) { 471 - pch_dbg(adap, "Receive NACK for slave address" 472 - "setting\n"); 473 - return -EIO; 474 - } 475 - pch_clrbit(adap->pch_base_address, PCH_I2CSR, 476 - I2CMCF_BIT); 477 - pch_clrbit(adap->pch_base_address, PCH_I2CSR, 478 - I2CMIF_BIT); 479 - } else { /* wait-event timeout */ 480 - pch_i2c_stop(adap); 481 - return -ETIME; 482 - } 467 + rtn = pch_i2c_wait_for_check_xfer(adap); 468 + if (rtn) 469 + return rtn; 470 + 471 + pch_clrbit(adap->pch_base_address, PCH_I2CSR, I2CMCF_BIT); 472 + pch_clrbit(adap->pch_base_address, PCH_I2CSR, I2CMIF_BIT); 483 473 } 484 474 485 475 /* check if this is the last message */ ··· 544 580 if (first) 545 581 pch_i2c_start(adap); 546 582 547 - rtn = pch_i2c_wait_for_xfer_complete(adap); 548 - if (rtn == 0) { 549 - if (pch_i2c_getack(adap)) { 550 - pch_dbg(adap, "Receive NACK for slave address" 551 - "setting\n"); 552 - return -EIO; 553 - } 554 - addr_8_lsb = (addr & I2C_ADDR_MSK); 555 - iowrite32(addr_8_lsb, p + PCH_I2CDR); 556 - } else if (rtn == -EIO) { /* Arbitration Lost */ 557 - pch_err(adap, "Lost Arbitration\n"); 558 - pch_clrbit(adap->pch_base_address, PCH_I2CSR, 559 - I2CMAL_BIT); 560 - pch_clrbit(adap->pch_base_address, PCH_I2CSR, 561 - I2CMIF_BIT); 562 - pch_i2c_init(adap); 563 - return -EAGAIN; 564 - } else { /* wait-event timeout */ 565 - pch_i2c_stop(adap); 566 - return -ETIME; 567 - } 583 + rtn = pch_i2c_wait_for_check_xfer(adap); 584 + if (rtn) 585 + return rtn; 586 + 587 + addr_8_lsb = (addr & I2C_ADDR_MSK); 588 + iowrite32(addr_8_lsb, p + PCH_I2CDR); 589 + 568 590 pch_i2c_restart(adap); 569 - rtn = pch_i2c_wait_for_xfer_complete(adap); 570 - if (rtn == 0) { 571 - if (pch_i2c_getack(adap)) { 572 - pch_dbg(adap, "Receive NACK for slave address" 573 - "setting\n"); 574 - return -EIO; 575 - } 576 - addr_2_msb |= I2C_RD; 577 - iowrite32(addr_2_msb | TEN_BIT_ADDR_MASK, 578 - p + PCH_I2CDR); 579 - } else if (rtn == -EIO) { /* Arbitration Lost */ 580 - pch_err(adap, "Lost Arbitration\n"); 581 - pch_clrbit(adap->pch_base_address, PCH_I2CSR, 582 - I2CMAL_BIT); 583 - pch_clrbit(adap->pch_base_address, PCH_I2CSR, 584 - I2CMIF_BIT); 585 - pch_i2c_init(adap); 586 - return -EAGAIN; 587 - } else { /* wait-event timeout */ 588 - pch_i2c_stop(adap); 589 - return -ETIME; 590 - } 591 + 592 + rtn = pch_i2c_wait_for_check_xfer(adap); 593 + if (rtn) 594 + return rtn; 595 + 596 + addr_2_msb |= I2C_RD; 597 + iowrite32(addr_2_msb | TEN_BIT_ADDR_MASK, p + PCH_I2CDR); 591 598 } else { 592 599 /* 7 address bits + R/W bit */ 593 600 addr = (((addr) << 1) | (I2C_RD)); ··· 569 634 if (first) 570 635 pch_i2c_start(adap); 571 636 572 - rtn = pch_i2c_wait_for_xfer_complete(adap); 573 - if (rtn == 0) { 574 - if (pch_i2c_getack(adap)) { 575 - pch_dbg(adap, "Receive NACK for slave address" 576 - "setting\n"); 577 - return -EIO; 578 - } 579 - } else if (rtn == -EIO) { /* Arbitration Lost */ 580 - pch_err(adap, "Lost Arbitration\n"); 581 - pch_clrbit(adap->pch_base_address, PCH_I2CSR, I2CMAL_BIT); 582 - pch_clrbit(adap->pch_base_address, PCH_I2CSR, I2CMIF_BIT); 583 - pch_i2c_init(adap); 584 - return -EAGAIN; 585 - } else { /* wait-event timeout */ 586 - pch_i2c_stop(adap); 587 - return -ETIME; 588 - } 637 + rtn = pch_i2c_wait_for_check_xfer(adap); 638 + if (rtn) 639 + return rtn; 589 640 590 641 if (length == 0) { 591 642 pch_i2c_stop(adap); ··· 590 669 if (loop != 1) 591 670 read_index++; 592 671 593 - rtn = pch_i2c_wait_for_xfer_complete(adap); 594 - if (rtn == 0) { 595 - if (pch_i2c_getack(adap)) { 596 - pch_dbg(adap, "Receive NACK for slave" 597 - "address setting\n"); 598 - return -EIO; 599 - } 600 - } else { /* wait-event timeout */ 601 - pch_i2c_stop(adap); 602 - return -ETIME; 603 - } 604 - 672 + rtn = pch_i2c_wait_for_check_xfer(adap); 673 + if (rtn) 674 + return rtn; 605 675 } /* end for */ 606 676 607 677 pch_i2c_sendnack(adap); ··· 602 690 if (length != 1) 603 691 read_index++; 604 692 605 - rtn = pch_i2c_wait_for_xfer_complete(adap); 606 - if (rtn == 0) { 607 - if (pch_i2c_getack(adap)) { 608 - pch_dbg(adap, "Receive NACK for slave" 609 - "address setting\n"); 610 - return -EIO; 611 - } 612 - } else { /* wait-event timeout */ 613 - pch_i2c_stop(adap); 614 - return -ETIME; 615 - } 693 + rtn = pch_i2c_wait_for_check_xfer(adap); 694 + if (rtn) 695 + return rtn; 616 696 617 697 if (last) 618 698 pch_i2c_stop(adap); ··· 694 790 695 791 ret = mutex_lock_interruptible(&pch_mutex); 696 792 if (ret) 697 - return -ERESTARTSYS; 793 + return ret; 698 794 699 795 if (adap->p_adapter_info->pch_i2c_suspended) { 700 796 mutex_unlock(&pch_mutex); ··· 813 909 814 910 pch_adap->owner = THIS_MODULE; 815 911 pch_adap->class = I2C_CLASS_HWMON; 816 - strcpy(pch_adap->name, KBUILD_MODNAME); 912 + strlcpy(pch_adap->name, KBUILD_MODNAME, sizeof(pch_adap->name)); 817 913 pch_adap->algo = &pch_algorithm; 818 914 pch_adap->algo_data = &adap_info->pch_data[i]; 819 915 ··· 867 963 pci_iounmap(pdev, adap_info->pch_data[0].pch_base_address); 868 964 869 965 for (i = 0; i < adap_info->ch_num; i++) 870 - adap_info->pch_data[i].pch_base_address = 0; 966 + adap_info->pch_data[i].pch_base_address = NULL; 871 967 872 968 pci_set_drvdata(pdev, NULL); 873 969
+1 -6
drivers/i2c/busses/i2c-gpio.c
··· 190 190 adap->dev.parent = &pdev->dev; 191 191 adap->dev.of_node = pdev->dev.of_node; 192 192 193 - /* 194 - * If "dev->id" is negative we consider it as zero. 195 - * The reason to do so is to avoid sysfs names that only make 196 - * sense when there are multiple adapters. 197 - */ 198 - adap->nr = (pdev->id != -1) ? pdev->id : 0; 193 + adap->nr = pdev->id; 199 194 ret = i2c_bit_add_numbered_bus(adap); 200 195 if (ret) 201 196 goto err_add_bus;
+1 -1
drivers/i2c/busses/i2c-imx.c
··· 512 512 } 513 513 514 514 /* Setup i2c_imx driver structure */ 515 - strcpy(i2c_imx->adapter.name, pdev->name); 515 + strlcpy(i2c_imx->adapter.name, pdev->name, sizeof(i2c_imx->adapter.name)); 516 516 i2c_imx->adapter.owner = THIS_MODULE; 517 517 i2c_imx->adapter.algo = &i2c_imx_algo; 518 518 i2c_imx->adapter.dev.parent = &pdev->dev;
-157
drivers/i2c/busses/i2c-ixp2000.c
··· 1 - /* 2 - * drivers/i2c/busses/i2c-ixp2000.c 3 - * 4 - * I2C adapter for IXP2000 systems using GPIOs for I2C bus 5 - * 6 - * Author: Deepak Saxena <dsaxena@plexity.net> 7 - * Based on IXDP2400 code by: Naeem M. Afzal <naeem.m.afzal@intel.com> 8 - * Made generic by: Jeff Daly <jeffrey.daly@intel.com> 9 - * 10 - * Copyright (c) 2003-2004 MontaVista Software Inc. 11 - * 12 - * This file is licensed under the terms of the GNU General Public 13 - * License version 2. This program is licensed "as is" without any 14 - * warranty of any kind, whether express or implied. 15 - * 16 - * From Jeff Daly: 17 - * 18 - * I2C adapter driver for Intel IXDP2xxx platforms. This should work for any 19 - * IXP2000 platform if it uses the HW GPIO in the same manner. Basically, 20 - * SDA and SCL GPIOs have external pullups. Setting the respective GPIO to 21 - * an input will make the signal a '1' via the pullup. Setting them to 22 - * outputs will pull them down. 23 - * 24 - * The GPIOs are open drain signals and are used as configuration strap inputs 25 - * during power-up so there's generally a buffer on the board that needs to be 26 - * 'enabled' to drive the GPIOs. 27 - */ 28 - 29 - #include <linux/kernel.h> 30 - #include <linux/init.h> 31 - #include <linux/platform_device.h> 32 - #include <linux/module.h> 33 - #include <linux/i2c.h> 34 - #include <linux/i2c-algo-bit.h> 35 - #include <linux/slab.h> 36 - 37 - #include <mach/hardware.h> /* Pick up IXP2000-specific bits */ 38 - #include <mach/gpio-ixp2000.h> 39 - 40 - static inline int ixp2000_scl_pin(void *data) 41 - { 42 - return ((struct ixp2000_i2c_pins*)data)->scl_pin; 43 - } 44 - 45 - static inline int ixp2000_sda_pin(void *data) 46 - { 47 - return ((struct ixp2000_i2c_pins*)data)->sda_pin; 48 - } 49 - 50 - 51 - static void ixp2000_bit_setscl(void *data, int val) 52 - { 53 - int i = 5000; 54 - 55 - if (val) { 56 - gpio_line_config(ixp2000_scl_pin(data), GPIO_IN); 57 - while(!gpio_line_get(ixp2000_scl_pin(data)) && i--); 58 - } else { 59 - gpio_line_config(ixp2000_scl_pin(data), GPIO_OUT); 60 - } 61 - } 62 - 63 - static void ixp2000_bit_setsda(void *data, int val) 64 - { 65 - if (val) { 66 - gpio_line_config(ixp2000_sda_pin(data), GPIO_IN); 67 - } else { 68 - gpio_line_config(ixp2000_sda_pin(data), GPIO_OUT); 69 - } 70 - } 71 - 72 - static int ixp2000_bit_getscl(void *data) 73 - { 74 - return gpio_line_get(ixp2000_scl_pin(data)); 75 - } 76 - 77 - static int ixp2000_bit_getsda(void *data) 78 - { 79 - return gpio_line_get(ixp2000_sda_pin(data)); 80 - } 81 - 82 - struct ixp2000_i2c_data { 83 - struct ixp2000_i2c_pins *gpio_pins; 84 - struct i2c_adapter adapter; 85 - struct i2c_algo_bit_data algo_data; 86 - }; 87 - 88 - static int ixp2000_i2c_remove(struct platform_device *plat_dev) 89 - { 90 - struct ixp2000_i2c_data *drv_data = platform_get_drvdata(plat_dev); 91 - 92 - platform_set_drvdata(plat_dev, NULL); 93 - 94 - i2c_del_adapter(&drv_data->adapter); 95 - 96 - kfree(drv_data); 97 - 98 - return 0; 99 - } 100 - 101 - static int ixp2000_i2c_probe(struct platform_device *plat_dev) 102 - { 103 - int err; 104 - struct ixp2000_i2c_pins *gpio = plat_dev->dev.platform_data; 105 - struct ixp2000_i2c_data *drv_data = 106 - kzalloc(sizeof(struct ixp2000_i2c_data), GFP_KERNEL); 107 - 108 - if (!drv_data) 109 - return -ENOMEM; 110 - drv_data->gpio_pins = gpio; 111 - 112 - drv_data->algo_data.data = gpio; 113 - drv_data->algo_data.setsda = ixp2000_bit_setsda; 114 - drv_data->algo_data.setscl = ixp2000_bit_setscl; 115 - drv_data->algo_data.getsda = ixp2000_bit_getsda; 116 - drv_data->algo_data.getscl = ixp2000_bit_getscl; 117 - drv_data->algo_data.udelay = 6; 118 - drv_data->algo_data.timeout = HZ; 119 - 120 - strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name, 121 - sizeof(drv_data->adapter.name)); 122 - drv_data->adapter.algo_data = &drv_data->algo_data, 123 - 124 - drv_data->adapter.dev.parent = &plat_dev->dev; 125 - 126 - gpio_line_config(gpio->sda_pin, GPIO_IN); 127 - gpio_line_config(gpio->scl_pin, GPIO_IN); 128 - gpio_line_set(gpio->scl_pin, 0); 129 - gpio_line_set(gpio->sda_pin, 0); 130 - 131 - if ((err = i2c_bit_add_bus(&drv_data->adapter)) != 0) { 132 - dev_err(&plat_dev->dev, "Could not install, error %d\n", err); 133 - kfree(drv_data); 134 - return err; 135 - } 136 - 137 - platform_set_drvdata(plat_dev, drv_data); 138 - 139 - return 0; 140 - } 141 - 142 - static struct platform_driver ixp2000_i2c_driver = { 143 - .probe = ixp2000_i2c_probe, 144 - .remove = ixp2000_i2c_remove, 145 - .driver = { 146 - .name = "IXP2000-I2C", 147 - .owner = THIS_MODULE, 148 - }, 149 - }; 150 - 151 - module_platform_driver(ixp2000_i2c_driver); 152 - 153 - MODULE_AUTHOR ("Deepak Saxena <dsaxena@plexity.net>"); 154 - MODULE_DESCRIPTION("IXP2000 GPIO-based I2C bus driver"); 155 - MODULE_LICENSE("GPL"); 156 - MODULE_ALIAS("platform:IXP2000-I2C"); 157 -
+30
drivers/i2c/busses/i2c-mpc.c
··· 64 64 struct i2c_adapter adap; 65 65 int irq; 66 66 u32 real_clk; 67 + #ifdef CONFIG_PM 68 + u8 fdr, dfsrr; 69 + #endif 67 70 }; 68 71 69 72 struct mpc_i2c_divider { ··· 706 703 return 0; 707 704 }; 708 705 706 + #ifdef CONFIG_PM 707 + static int mpc_i2c_suspend(struct device *dev) 708 + { 709 + struct mpc_i2c *i2c = dev_get_drvdata(dev); 710 + 711 + i2c->fdr = readb(i2c->base + MPC_I2C_FDR); 712 + i2c->dfsrr = readb(i2c->base + MPC_I2C_DFSRR); 713 + 714 + return 0; 715 + } 716 + 717 + static int mpc_i2c_resume(struct device *dev) 718 + { 719 + struct mpc_i2c *i2c = dev_get_drvdata(dev); 720 + 721 + writeb(i2c->fdr, i2c->base + MPC_I2C_FDR); 722 + writeb(i2c->dfsrr, i2c->base + MPC_I2C_DFSRR); 723 + 724 + return 0; 725 + } 726 + 727 + SIMPLE_DEV_PM_OPS(mpc_i2c_pm_ops, mpc_i2c_suspend, mpc_i2c_resume); 728 + #endif 729 + 709 730 static struct mpc_i2c_data mpc_i2c_data_512x __devinitdata = { 710 731 .setup = mpc_i2c_setup_512x, 711 732 }; ··· 774 747 .owner = THIS_MODULE, 775 748 .name = DRV_NAME, 776 749 .of_match_table = mpc_i2c_of_match, 750 + #ifdef CONFIG_PM 751 + .pm = &mpc_i2c_pm_ops, 752 + #endif 777 753 }, 778 754 }; 779 755
+3
drivers/i2c/busses/i2c-ocores.c
··· 55 55 #include <linux/i2c-ocores.h> 56 56 #include <linux/slab.h> 57 57 #include <linux/io.h> 58 + #include <linux/of_i2c.h> 58 59 59 60 struct ocores_i2c { 60 61 void __iomem *base; ··· 344 343 if (pdata) { 345 344 for (i = 0; i < pdata->num_devices; i++) 346 345 i2c_new_device(&i2c->adap, pdata->devices + i); 346 + } else { 347 + of_i2c_register_devices(&i2c->adap); 347 348 } 348 349 349 350 return 0;
+1 -1
drivers/i2c/busses/i2c-pca-platform.c
··· 171 171 i2c->io_size = resource_size(res); 172 172 i2c->irq = irq; 173 173 174 - i2c->adap.nr = pdev->id >= 0 ? pdev->id : 0; 174 + i2c->adap.nr = pdev->id; 175 175 i2c->adap.owner = THIS_MODULE; 176 176 snprintf(i2c->adap.name, sizeof(i2c->adap.name), 177 177 "PCA9564/PCA9665 at 0x%08lx",
-5
drivers/i2c/busses/i2c-pxa.c
··· 1131 1131 spin_lock_init(&i2c->lock); 1132 1132 init_waitqueue_head(&i2c->wait); 1133 1133 1134 - /* 1135 - * If "dev->id" is negative we consider it as zero. 1136 - * The reason to do so is to avoid sysfs names that only make 1137 - * sense when there are multiple adapters. 1138 - */ 1139 1134 i2c->adap.nr = dev->id; 1140 1135 snprintf(i2c->adap.name, sizeof(i2c->adap.name), "pxa_i2c-i2c.%u", 1141 1136 i2c->adap.nr);
+67 -46
drivers/i2c/busses/i2c-s3c2410.c
··· 44 44 #include <plat/regs-iic.h> 45 45 #include <plat/iic.h> 46 46 47 - /* i2c controller state */ 47 + /* Treat S3C2410 as baseline hardware, anything else is supported via quirks */ 48 + #define QUIRK_S3C2440 (1 << 0) 49 + #define QUIRK_HDMIPHY (1 << 1) 50 + #define QUIRK_NO_GPIO (1 << 2) 48 51 52 + /* i2c controller state */ 49 53 enum s3c24xx_i2c_state { 50 54 STATE_IDLE, 51 55 STATE_START, ··· 58 54 STATE_STOP 59 55 }; 60 56 61 - enum s3c24xx_i2c_type { 62 - TYPE_S3C2410, 63 - TYPE_S3C2440, 64 - }; 65 - 66 57 struct s3c24xx_i2c { 67 58 spinlock_t lock; 68 59 wait_queue_head_t wait; 60 + unsigned int quirks; 69 61 unsigned int suspended:1; 70 62 71 63 struct i2c_msg *msg; ··· 88 88 #endif 89 89 }; 90 90 91 - /* default platform data removed, dev should always carry data. */ 92 - 93 - /* s3c24xx_i2c_is2440() 94 - * 95 - * return true is this is an s3c2440 96 - */ 97 - 98 - static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c) 99 - { 100 - struct platform_device *pdev = to_platform_device(i2c->dev); 101 - enum s3c24xx_i2c_type type; 91 + static struct platform_device_id s3c24xx_driver_ids[] = { 92 + { 93 + .name = "s3c2410-i2c", 94 + .driver_data = 0, 95 + }, { 96 + .name = "s3c2440-i2c", 97 + .driver_data = QUIRK_S3C2440, 98 + }, { 99 + .name = "s3c2440-hdmiphy-i2c", 100 + .driver_data = QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO, 101 + }, { }, 102 + }; 103 + MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids); 102 104 103 105 #ifdef CONFIG_OF 104 - if (i2c->dev->of_node) 105 - return of_device_is_compatible(i2c->dev->of_node, 106 - "samsung,s3c2440-i2c"); 106 + static const struct of_device_id s3c24xx_i2c_match[] = { 107 + { .compatible = "samsung,s3c2410-i2c", .data = (void *)0 }, 108 + { .compatible = "samsung,s3c2440-i2c", .data = (void *)QUIRK_S3C2440 }, 109 + { .compatible = "samsung,s3c2440-hdmiphy-i2c", 110 + .data = (void *)(QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO) }, 111 + {}, 112 + }; 113 + MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match); 107 114 #endif 108 115 109 - type = platform_get_device_id(pdev)->driver_data; 110 - return type == TYPE_S3C2440; 116 + /* s3c24xx_get_device_quirks 117 + * 118 + * Get controller type either from device tree or platform device variant. 119 + */ 120 + 121 + static inline unsigned int s3c24xx_get_device_quirks(struct platform_device *pdev) 122 + { 123 + if (pdev->dev.of_node) { 124 + const struct of_device_id *match; 125 + match = of_match_node(&s3c24xx_i2c_match, pdev->dev.of_node); 126 + return (unsigned int)match->data; 127 + } 128 + 129 + return platform_get_device_id(pdev)->driver_data; 111 130 } 112 131 113 132 /* s3c24xx_i2c_master_complete ··· 490 471 unsigned long iicstat; 491 472 int timeout = 400; 492 473 474 + /* the timeout for HDMIPHY is reduced to 10 ms because 475 + * the hangup is expected to happen, so waiting 400 ms 476 + * causes only unnecessary system hangup 477 + */ 478 + if (i2c->quirks & QUIRK_HDMIPHY) 479 + timeout = 10; 480 + 493 481 while (timeout-- > 0) { 494 482 iicstat = readl(i2c->regs + S3C2410_IICSTAT); 495 483 ··· 504 478 return 0; 505 479 506 480 msleep(1); 481 + } 482 + 483 + /* hang-up of bus dedicated for HDMIPHY occurred, resetting */ 484 + if (i2c->quirks & QUIRK_HDMIPHY) { 485 + writel(0, i2c->regs + S3C2410_IICCON); 486 + writel(0, i2c->regs + S3C2410_IICSTAT); 487 + writel(0, i2c->regs + S3C2410_IICDS); 488 + 489 + return 0; 507 490 } 508 491 509 492 return -ETIMEDOUT; ··· 711 676 712 677 writel(iiccon, i2c->regs + S3C2410_IICCON); 713 678 714 - if (s3c24xx_i2c_is2440(i2c)) { 679 + if (i2c->quirks & QUIRK_S3C2440) { 715 680 unsigned long sda_delay; 716 681 717 682 if (pdata->sda_delay) { ··· 796 761 { 797 762 int idx, gpio, ret; 798 763 764 + if (i2c->quirks & QUIRK_NO_GPIO) 765 + return 0; 766 + 799 767 for (idx = 0; idx < 2; idx++) { 800 768 gpio = of_get_gpio(i2c->dev->of_node, idx); 801 769 if (!gpio_is_valid(gpio)) { ··· 823 785 static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c *i2c) 824 786 { 825 787 unsigned int idx; 788 + 789 + if (i2c->quirks & QUIRK_NO_GPIO) 790 + return; 791 + 826 792 for (idx = 0; idx < 2; idx++) 827 793 gpio_free(i2c->gpios[idx]); 828 794 } ··· 948 906 goto err_noclk; 949 907 } 950 908 909 + i2c->quirks = s3c24xx_get_device_quirks(pdev); 951 910 if (pdata) 952 911 memcpy(i2c->pdata, pdata, sizeof(*pdata)); 953 912 else ··· 1153 1110 1154 1111 /* device driver for platform bus bits */ 1155 1112 1156 - static struct platform_device_id s3c24xx_driver_ids[] = { 1157 - { 1158 - .name = "s3c2410-i2c", 1159 - .driver_data = TYPE_S3C2410, 1160 - }, { 1161 - .name = "s3c2440-i2c", 1162 - .driver_data = TYPE_S3C2440, 1163 - }, { }, 1164 - }; 1165 - MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids); 1166 - 1167 - #ifdef CONFIG_OF 1168 - static const struct of_device_id s3c24xx_i2c_match[] = { 1169 - { .compatible = "samsung,s3c2410-i2c" }, 1170 - { .compatible = "samsung,s3c2440-i2c" }, 1171 - {}, 1172 - }; 1173 - MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match); 1174 - #else 1175 - #define s3c24xx_i2c_match NULL 1176 - #endif 1177 - 1178 1113 static struct platform_driver s3c24xx_i2c_driver = { 1179 1114 .probe = s3c24xx_i2c_probe, 1180 1115 .remove = s3c24xx_i2c_remove, ··· 1161 1140 .owner = THIS_MODULE, 1162 1141 .name = "s3c-i2c", 1163 1142 .pm = S3C24XX_DEV_PM_OPS, 1164 - .of_match_table = s3c24xx_i2c_match, 1143 + .of_match_table = of_match_ptr(s3c24xx_i2c_match), 1165 1144 }, 1166 1145 }; 1167 1146
+11
drivers/i2c/busses/i2c-sh_mobile.c
··· 27 27 #include <linux/platform_device.h> 28 28 #include <linux/interrupt.h> 29 29 #include <linux/i2c.h> 30 + #include <linux/of_i2c.h> 30 31 #include <linux/err.h> 31 32 #include <linux/pm_runtime.h> 32 33 #include <linux/clk.h> ··· 654 653 adap->dev.parent = &dev->dev; 655 654 adap->retries = 5; 656 655 adap->nr = dev->id; 656 + adap->dev.of_node = dev->dev.of_node; 657 657 658 658 strlcpy(adap->name, dev->name, sizeof(adap->name)); 659 659 ··· 669 667 670 668 dev_info(&dev->dev, "I2C adapter %d with bus speed %lu Hz\n", 671 669 adap->nr, pd->bus_speed); 670 + 671 + of_i2c_register_devices(adap); 672 672 return 0; 673 673 674 674 err_all: ··· 714 710 .runtime_resume = sh_mobile_i2c_runtime_nop, 715 711 }; 716 712 713 + static const struct of_device_id sh_mobile_i2c_dt_ids[] __devinitconst = { 714 + { .compatible = "renesas,rmobile-iic", }, 715 + {}, 716 + }; 717 + MODULE_DEVICE_TABLE(of, sh_mobile_i2c_dt_ids); 718 + 717 719 static struct platform_driver sh_mobile_i2c_driver = { 718 720 .driver = { 719 721 .name = "i2c-sh_mobile", 720 722 .owner = THIS_MODULE, 721 723 .pm = &sh_mobile_i2c_dev_pm_ops, 724 + .of_match_table = sh_mobile_i2c_dt_ids, 722 725 }, 723 726 .probe = sh_mobile_i2c_probe, 724 727 .remove = sh_mobile_i2c_remove,
+13 -11
drivers/i2c/busses/i2c-tegra.c
··· 401 401 disable_irq_nosync(i2c_dev->irq); 402 402 i2c_dev->irq_disabled = 1; 403 403 } 404 - 405 - complete(&i2c_dev->msg_complete); 406 404 goto err; 407 405 } 408 406 ··· 409 411 i2c_dev->msg_err |= I2C_ERR_NO_ACK; 410 412 if (status & I2C_INT_ARBITRATION_LOST) 411 413 i2c_dev->msg_err |= I2C_ERR_ARBITRATION_LOST; 412 - complete(&i2c_dev->msg_complete); 413 414 goto err; 414 415 } 415 416 ··· 426 429 tegra_i2c_mask_irq(i2c_dev, I2C_INT_TX_FIFO_DATA_REQ); 427 430 } 428 431 432 + i2c_writel(i2c_dev, status, I2C_INT_STATUS); 433 + if (i2c_dev->is_dvc) 434 + dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS); 435 + 429 436 if (status & I2C_INT_PACKET_XFER_COMPLETE) { 430 437 BUG_ON(i2c_dev->msg_buf_remaining); 431 438 complete(&i2c_dev->msg_complete); 432 439 } 433 - 434 - i2c_writel(i2c_dev, status, I2C_INT_STATUS); 435 - if (i2c_dev->is_dvc) 436 - dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS); 437 440 return IRQ_HANDLED; 438 441 err: 439 442 /* An error occurred, mask all interrupts */ ··· 443 446 i2c_writel(i2c_dev, status, I2C_INT_STATUS); 444 447 if (i2c_dev->is_dvc) 445 448 dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS); 449 + 450 + complete(&i2c_dev->msg_complete); 446 451 return IRQ_HANDLED; 447 452 } 448 453 ··· 475 476 packet_header = msg->len - 1; 476 477 i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); 477 478 478 - packet_header = msg->addr << I2C_HEADER_SLAVE_ADDR_SHIFT; 479 - packet_header |= I2C_HEADER_IE_ENABLE; 479 + packet_header = I2C_HEADER_IE_ENABLE; 480 480 if (!stop) 481 481 packet_header |= I2C_HEADER_REPEAT_START; 482 - if (msg->flags & I2C_M_TEN) 482 + if (msg->flags & I2C_M_TEN) { 483 + packet_header |= msg->addr; 483 484 packet_header |= I2C_HEADER_10BIT_ADDR; 485 + } else { 486 + packet_header |= msg->addr << I2C_HEADER_SLAVE_ADDR_SHIFT; 487 + } 484 488 if (msg->flags & I2C_M_IGNORE_NAK) 485 489 packet_header |= I2C_HEADER_CONT_ON_NAK; 486 490 if (msg->flags & I2C_M_RD) ··· 559 557 560 558 static u32 tegra_i2c_func(struct i2c_adapter *adap) 561 559 { 562 - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 560 + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR; 563 561 } 564 562 565 563 static const struct i2c_algorithm tegra_i2c_algo = {
+2 -7
drivers/i2c/busses/i2c-versatile.c
··· 104 104 i2c->algo = i2c_versatile_algo; 105 105 i2c->algo.data = i2c; 106 106 107 - if (dev->id >= 0) { 108 - /* static bus numbering */ 109 - i2c->adap.nr = dev->id; 110 - ret = i2c_bit_add_numbered_bus(&i2c->adap); 111 - } else 112 - /* dynamic bus numbering */ 113 - ret = i2c_bit_add_bus(&i2c->adap); 107 + i2c->adap.nr = dev->id; 108 + ret = i2c_bit_add_numbered_bus(&i2c->adap); 114 109 if (ret >= 0) { 115 110 platform_set_drvdata(dev, i2c); 116 111 of_i2c_register_devices(&i2c->adap);
+18 -5
drivers/i2c/busses/i2c-xiic.c
··· 40 40 #include <linux/i2c-xiic.h> 41 41 #include <linux/io.h> 42 42 #include <linux/slab.h> 43 + #include <linux/of_i2c.h> 43 44 44 45 #define DRIVER_NAME "xiic-i2c" 45 46 ··· 706 705 goto resource_missing; 707 706 708 707 pdata = (struct xiic_i2c_platform_data *) pdev->dev.platform_data; 709 - if (!pdata) 710 - return -EINVAL; 711 708 712 709 i2c = kzalloc(sizeof(*i2c), GFP_KERNEL); 713 710 if (!i2c) ··· 729 730 i2c->adap = xiic_adapter; 730 731 i2c_set_adapdata(&i2c->adap, i2c); 731 732 i2c->adap.dev.parent = &pdev->dev; 733 + i2c->adap.dev.of_node = pdev->dev.of_node; 732 734 733 735 xiic_reinit(i2c); 734 736 ··· 748 748 goto add_adapter_failed; 749 749 } 750 750 751 - /* add in known devices to the bus */ 752 - for (i = 0; i < pdata->num_devices; i++) 753 - i2c_new_device(&i2c->adap, pdata->devices + i); 751 + if (pdata) { 752 + /* add in known devices to the bus */ 753 + for (i = 0; i < pdata->num_devices; i++) 754 + i2c_new_device(&i2c->adap, pdata->devices + i); 755 + } 756 + 757 + of_i2c_register_devices(&i2c->adap); 754 758 755 759 return 0; 756 760 ··· 799 795 return 0; 800 796 } 801 797 798 + #if defined(CONFIG_OF) 799 + static const struct of_device_id xiic_of_match[] __devinitconst = { 800 + { .compatible = "xlnx,xps-iic-2.00.a", }, 801 + {}, 802 + }; 803 + MODULE_DEVICE_TABLE(of, xiic_of_match); 804 + #endif 805 + 802 806 static struct platform_driver xiic_i2c_driver = { 803 807 .probe = xiic_i2c_probe, 804 808 .remove = __devexit_p(xiic_i2c_remove), 805 809 .driver = { 806 810 .owner = THIS_MODULE, 807 811 .name = DRIVER_NAME, 812 + .of_match_table = of_match_ptr(xiic_of_match), 808 813 }, 809 814 }; 810 815
+17
drivers/i2c/i2c-core.c
··· 772 772 }; 773 773 EXPORT_SYMBOL_GPL(i2c_adapter_type); 774 774 775 + /** 776 + * i2c_verify_adapter - return parameter as i2c_adapter or NULL 777 + * @dev: device, probably from some driver model iterator 778 + * 779 + * When traversing the driver model tree, perhaps using driver model 780 + * iterators like @device_for_each_child(), you can't assume very much 781 + * about the nodes you find. Use this function to avoid oopses caused 782 + * by wrongly treating some non-I2C device as an i2c_adapter. 783 + */ 784 + struct i2c_adapter *i2c_verify_adapter(struct device *dev) 785 + { 786 + return (dev->type == &i2c_adapter_type) 787 + ? to_i2c_adapter(dev) 788 + : NULL; 789 + } 790 + EXPORT_SYMBOL(i2c_verify_adapter); 791 + 775 792 #ifdef CONFIG_I2C_COMPAT 776 793 static struct class_compat *i2c_adapter_compat_class; 777 794 #endif
+33 -9
drivers/i2c/i2c-mux.c
··· 24 24 #include <linux/slab.h> 25 25 #include <linux/i2c.h> 26 26 #include <linux/i2c-mux.h> 27 + #include <linux/of.h> 28 + #include <linux/of_i2c.h> 27 29 28 30 /* multiplexer per channel data */ 29 31 struct i2c_mux_priv { ··· 33 31 struct i2c_algorithm algo; 34 32 35 33 struct i2c_adapter *parent; 36 - void *mux_dev; /* the mux chip/device */ 34 + void *mux_priv; /* the mux chip/device */ 37 35 u32 chan_id; /* the channel id */ 38 36 39 - int (*select)(struct i2c_adapter *, void *mux_dev, u32 chan_id); 40 - int (*deselect)(struct i2c_adapter *, void *mux_dev, u32 chan_id); 37 + int (*select)(struct i2c_adapter *, void *mux_priv, u32 chan_id); 38 + int (*deselect)(struct i2c_adapter *, void *mux_priv, u32 chan_id); 41 39 }; 42 40 43 41 static int i2c_mux_master_xfer(struct i2c_adapter *adap, ··· 49 47 50 48 /* Switch to the right mux port and perform the transfer. */ 51 49 52 - ret = priv->select(parent, priv->mux_dev, priv->chan_id); 50 + ret = priv->select(parent, priv->mux_priv, priv->chan_id); 53 51 if (ret >= 0) 54 52 ret = parent->algo->master_xfer(parent, msgs, num); 55 53 if (priv->deselect) 56 - priv->deselect(parent, priv->mux_dev, priv->chan_id); 54 + priv->deselect(parent, priv->mux_priv, priv->chan_id); 57 55 58 56 return ret; 59 57 } ··· 69 67 70 68 /* Select the right mux port and perform the transfer. */ 71 69 72 - ret = priv->select(parent, priv->mux_dev, priv->chan_id); 70 + ret = priv->select(parent, priv->mux_priv, priv->chan_id); 73 71 if (ret >= 0) 74 72 ret = parent->algo->smbus_xfer(parent, addr, flags, 75 73 read_write, command, size, data); 76 74 if (priv->deselect) 77 - priv->deselect(parent, priv->mux_dev, priv->chan_id); 75 + priv->deselect(parent, priv->mux_priv, priv->chan_id); 78 76 79 77 return ret; 80 78 } ··· 89 87 } 90 88 91 89 struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent, 92 - void *mux_dev, u32 force_nr, u32 chan_id, 90 + struct device *mux_dev, 91 + void *mux_priv, u32 force_nr, u32 chan_id, 93 92 int (*select) (struct i2c_adapter *, 94 93 void *, u32), 95 94 int (*deselect) (struct i2c_adapter *, ··· 105 102 106 103 /* Set up private adapter data */ 107 104 priv->parent = parent; 108 - priv->mux_dev = mux_dev; 105 + priv->mux_priv = mux_priv; 109 106 priv->chan_id = chan_id; 110 107 priv->select = select; 111 108 priv->deselect = deselect; ··· 127 124 priv->adap.algo_data = priv; 128 125 priv->adap.dev.parent = &parent->dev; 129 126 127 + /* 128 + * Try to populate the mux adapter's of_node, expands to 129 + * nothing if !CONFIG_OF. 130 + */ 131 + if (mux_dev->of_node) { 132 + struct device_node *child; 133 + u32 reg; 134 + 135 + for_each_child_of_node(mux_dev->of_node, child) { 136 + ret = of_property_read_u32(child, "reg", &reg); 137 + if (ret) 138 + continue; 139 + if (chan_id == reg) { 140 + priv->adap.dev.of_node = child; 141 + break; 142 + } 143 + } 144 + } 145 + 130 146 if (force_nr) { 131 147 priv->adap.nr = force_nr; 132 148 ret = i2c_add_numbered_adapter(&priv->adap); ··· 162 140 163 141 dev_info(&parent->dev, "Added multiplexed i2c bus %d\n", 164 142 i2c_adapter_id(&priv->adap)); 143 + 144 + of_i2c_register_devices(&priv->adap); 165 145 166 146 return &priv->adap; 167 147 }
+3 -3
drivers/i2c/muxes/Kconfig
··· 15 15 through GPIO pins. 16 16 17 17 This driver can also be built as a module. If so, the module 18 - will be called gpio-i2cmux. 18 + will be called i2c-mux-gpio. 19 19 20 20 config I2C_MUX_PCA9541 21 21 tristate "NXP PCA9541 I2C Master Selector" ··· 25 25 I2C Master Selector. 26 26 27 27 This driver can also be built as a module. If so, the module 28 - will be called pca9541. 28 + will be called i2c-mux-pca9541. 29 29 30 30 config I2C_MUX_PCA954x 31 31 tristate "Philips PCA954x I2C Mux/switches" ··· 35 35 I2C mux/switch devices. 36 36 37 37 This driver can also be built as a module. If so, the module 38 - will be called pca954x. 38 + will be called i2c-mux-pca954x. 39 39 40 40 endmenu
+3 -3
drivers/i2c/muxes/Makefile
··· 1 1 # 2 2 # Makefile for multiplexer I2C chip drivers. 3 3 4 - obj-$(CONFIG_I2C_MUX_GPIO) += gpio-i2cmux.o 5 - obj-$(CONFIG_I2C_MUX_PCA9541) += pca9541.o 6 - obj-$(CONFIG_I2C_MUX_PCA954x) += pca954x.o 4 + obj-$(CONFIG_I2C_MUX_GPIO) += i2c-mux-gpio.o 5 + obj-$(CONFIG_I2C_MUX_PCA9541) += i2c-mux-pca9541.o 6 + obj-$(CONFIG_I2C_MUX_PCA954x) += i2c-mux-pca954x.o 7 7 8 8 ccflags-$(CONFIG_I2C_DEBUG_BUS) := -DDEBUG
+21 -21
drivers/i2c/muxes/gpio-i2cmux.c drivers/i2c/muxes/i2c-mux-gpio.c
··· 10 10 11 11 #include <linux/i2c.h> 12 12 #include <linux/i2c-mux.h> 13 - #include <linux/gpio-i2cmux.h> 13 + #include <linux/i2c-mux-gpio.h> 14 14 #include <linux/platform_device.h> 15 15 #include <linux/init.h> 16 16 #include <linux/module.h> ··· 20 20 struct gpiomux { 21 21 struct i2c_adapter *parent; 22 22 struct i2c_adapter **adap; /* child busses */ 23 - struct gpio_i2cmux_platform_data data; 23 + struct i2c_mux_gpio_platform_data data; 24 24 }; 25 25 26 - static void gpiomux_set(const struct gpiomux *mux, unsigned val) 26 + static void i2c_mux_gpio_set(const struct gpiomux *mux, unsigned val) 27 27 { 28 28 int i; 29 29 ··· 31 31 gpio_set_value(mux->data.gpios[i], val & (1 << i)); 32 32 } 33 33 34 - static int gpiomux_select(struct i2c_adapter *adap, void *data, u32 chan) 34 + static int i2c_mux_gpio_select(struct i2c_adapter *adap, void *data, u32 chan) 35 35 { 36 36 struct gpiomux *mux = data; 37 37 38 - gpiomux_set(mux, mux->data.values[chan]); 38 + i2c_mux_gpio_set(mux, mux->data.values[chan]); 39 39 40 40 return 0; 41 41 } 42 42 43 - static int gpiomux_deselect(struct i2c_adapter *adap, void *data, u32 chan) 43 + static int i2c_mux_gpio_deselect(struct i2c_adapter *adap, void *data, u32 chan) 44 44 { 45 45 struct gpiomux *mux = data; 46 46 47 - gpiomux_set(mux, mux->data.idle); 47 + i2c_mux_gpio_set(mux, mux->data.idle); 48 48 49 49 return 0; 50 50 } 51 51 52 - static int __devinit gpiomux_probe(struct platform_device *pdev) 52 + static int __devinit i2c_mux_gpio_probe(struct platform_device *pdev) 53 53 { 54 54 struct gpiomux *mux; 55 - struct gpio_i2cmux_platform_data *pdata; 55 + struct i2c_mux_gpio_platform_data *pdata; 56 56 struct i2c_adapter *parent; 57 57 int (*deselect) (struct i2c_adapter *, void *, u32); 58 58 unsigned initial_state; ··· 86 86 goto alloc_failed2; 87 87 } 88 88 89 - if (pdata->idle != GPIO_I2CMUX_NO_IDLE) { 89 + if (pdata->idle != I2C_MUX_GPIO_NO_IDLE) { 90 90 initial_state = pdata->idle; 91 - deselect = gpiomux_deselect; 91 + deselect = i2c_mux_gpio_deselect; 92 92 } else { 93 93 initial_state = pdata->values[0]; 94 94 deselect = NULL; 95 95 } 96 96 97 97 for (i = 0; i < pdata->n_gpios; i++) { 98 - ret = gpio_request(pdata->gpios[i], "gpio-i2cmux"); 98 + ret = gpio_request(pdata->gpios[i], "i2c-mux-gpio"); 99 99 if (ret) 100 100 goto err_request_gpio; 101 101 gpio_direction_output(pdata->gpios[i], ··· 105 105 for (i = 0; i < pdata->n_values; i++) { 106 106 u32 nr = pdata->base_nr ? (pdata->base_nr + i) : 0; 107 107 108 - mux->adap[i] = i2c_add_mux_adapter(parent, mux, nr, i, 109 - gpiomux_select, deselect); 108 + mux->adap[i] = i2c_add_mux_adapter(parent, &pdev->dev, mux, nr, i, 109 + i2c_mux_gpio_select, deselect); 110 110 if (!mux->adap[i]) { 111 111 ret = -ENODEV; 112 112 dev_err(&pdev->dev, "Failed to add adapter %d\n", i); ··· 137 137 return ret; 138 138 } 139 139 140 - static int __devexit gpiomux_remove(struct platform_device *pdev) 140 + static int __devexit i2c_mux_gpio_remove(struct platform_device *pdev) 141 141 { 142 142 struct gpiomux *mux = platform_get_drvdata(pdev); 143 143 int i; ··· 156 156 return 0; 157 157 } 158 158 159 - static struct platform_driver gpiomux_driver = { 160 - .probe = gpiomux_probe, 161 - .remove = __devexit_p(gpiomux_remove), 159 + static struct platform_driver i2c_mux_gpio_driver = { 160 + .probe = i2c_mux_gpio_probe, 161 + .remove = __devexit_p(i2c_mux_gpio_remove), 162 162 .driver = { 163 163 .owner = THIS_MODULE, 164 - .name = "gpio-i2cmux", 164 + .name = "i2c-mux-gpio", 165 165 }, 166 166 }; 167 167 168 - module_platform_driver(gpiomux_driver); 168 + module_platform_driver(i2c_mux_gpio_driver); 169 169 170 170 MODULE_DESCRIPTION("GPIO-based I2C multiplexer driver"); 171 171 MODULE_AUTHOR("Peter Korsgaard <peter.korsgaard@barco.com>"); 172 172 MODULE_LICENSE("GPL"); 173 - MODULE_ALIAS("platform:gpio-i2cmux"); 173 + MODULE_ALIAS("platform:i2c-mux-gpio");
+2 -1
drivers/i2c/muxes/pca9541.c drivers/i2c/muxes/i2c-mux-pca9541.c
··· 353 353 force = 0; 354 354 if (pdata) 355 355 force = pdata->modes[0].adap_id; 356 - data->mux_adap = i2c_add_mux_adapter(adap, client, force, 0, 356 + data->mux_adap = i2c_add_mux_adapter(adap, &client->dev, client, 357 + force, 0, 357 358 pca9541_select_chan, 358 359 pca9541_release_chan); 359 360
+1 -1
drivers/i2c/muxes/pca954x.c drivers/i2c/muxes/i2c-mux-pca954x.c
··· 226 226 } 227 227 228 228 data->virt_adaps[num] = 229 - i2c_add_mux_adapter(adap, client, 229 + i2c_add_mux_adapter(adap, &client->dev, client, 230 230 force, num, pca954x_select_chan, 231 231 (pdata && pdata->modes[num].deselect_on_exit) 232 232 ? pca954x_deselect_mux : NULL);
+15 -1
drivers/of/of_i2c.c
··· 90 90 if (!dev) 91 91 return NULL; 92 92 93 - return to_i2c_client(dev); 93 + return i2c_verify_client(dev); 94 94 } 95 95 EXPORT_SYMBOL(of_find_i2c_device_by_node); 96 + 97 + /* must call put_device() when done with returned i2c_adapter device */ 98 + struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node) 99 + { 100 + struct device *dev; 101 + 102 + dev = bus_find_device(&i2c_bus_type, NULL, node, 103 + of_dev_node_match); 104 + if (!dev) 105 + return NULL; 106 + 107 + return i2c_verify_adapter(dev); 108 + } 109 + EXPORT_SYMBOL(of_find_i2c_adapter_by_node); 96 110 97 111 MODULE_LICENSE("GPL");
+7 -7
include/linux/gpio-i2cmux.h include/linux/i2c-mux-gpio.h
··· 1 1 /* 2 - * gpio-i2cmux interface to platform code 2 + * i2c-mux-gpio interface to platform code 3 3 * 4 4 * Peter Korsgaard <peter.korsgaard@barco.com> 5 5 * ··· 8 8 * published by the Free Software Foundation. 9 9 */ 10 10 11 - #ifndef _LINUX_GPIO_I2CMUX_H 12 - #define _LINUX_GPIO_I2CMUX_H 11 + #ifndef _LINUX_I2C_MUX_GPIO_H 12 + #define _LINUX_I2C_MUX_GPIO_H 13 13 14 14 /* MUX has no specific idle mode */ 15 - #define GPIO_I2CMUX_NO_IDLE ((unsigned)-1) 15 + #define I2C_MUX_GPIO_NO_IDLE ((unsigned)-1) 16 16 17 17 /** 18 - * struct gpio_i2cmux_platform_data - Platform-dependent data for gpio-i2cmux 18 + * struct i2c_mux_gpio_platform_data - Platform-dependent data for i2c-mux-gpio 19 19 * @parent: Parent I2C bus adapter number 20 20 * @base_nr: Base I2C bus number to number adapters from or zero for dynamic 21 21 * @values: Array of bitmasks of GPIO settings (low/high) for each ··· 25 25 * @n_gpios: Number of GPIOs used to control MUX 26 26 * @idle: Bitmask to write to MUX when idle or GPIO_I2CMUX_NO_IDLE if not used 27 27 */ 28 - struct gpio_i2cmux_platform_data { 28 + struct i2c_mux_gpio_platform_data { 29 29 int parent; 30 30 int base_nr; 31 31 const unsigned *values; ··· 35 35 unsigned idle; 36 36 }; 37 37 38 - #endif /* _LINUX_GPIO_I2CMUX_H */ 38 + #endif /* _LINUX_I2C_MUX_GPIO_H */
+2 -1
include/linux/i2c-mux.h
··· 34 34 * mux control. 35 35 */ 36 36 struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent, 37 - void *mux_dev, u32 force_nr, u32 chan_id, 37 + struct device *mux_dev, 38 + void *mux_priv, u32 force_nr, u32 chan_id, 38 39 int (*select) (struct i2c_adapter *, 39 40 void *mux_dev, u32 chan_id), 40 41 int (*deselect) (struct i2c_adapter *,
+1
include/linux/i2c.h
··· 232 232 #define to_i2c_client(d) container_of(d, struct i2c_client, dev) 233 233 234 234 extern struct i2c_client *i2c_verify_client(struct device *dev); 235 + extern struct i2c_adapter *i2c_verify_adapter(struct device *dev); 235 236 236 237 static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj) 237 238 {
+4
include/linux/of_i2c.h
··· 20 20 /* must call put_device() when done with returned i2c_client device */ 21 21 extern struct i2c_client *of_find_i2c_device_by_node(struct device_node *node); 22 22 23 + /* must call put_device() when done with returned i2c_adapter device */ 24 + extern struct i2c_adapter *of_find_i2c_adapter_by_node( 25 + struct device_node *node); 26 + 23 27 #else 24 28 static inline void of_i2c_register_devices(struct i2c_adapter *adap) 25 29 {