diff options
Diffstat (limited to 'drivers/i2c')
40 files changed, 106 insertions, 551 deletions
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index 02ce9cff5fcf..d06083fdffbb 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig | |||
@@ -73,7 +73,6 @@ config I2C_SMBUS | |||
73 | 73 | ||
74 | source drivers/i2c/algos/Kconfig | 74 | source drivers/i2c/algos/Kconfig |
75 | source drivers/i2c/busses/Kconfig | 75 | source drivers/i2c/busses/Kconfig |
76 | source drivers/i2c/chips/Kconfig | ||
77 | 76 | ||
78 | config I2C_DEBUG_CORE | 77 | config I2C_DEBUG_CORE |
79 | bool "I2C Core debugging messages" | 78 | bool "I2C Core debugging messages" |
@@ -98,12 +97,4 @@ config I2C_DEBUG_BUS | |||
98 | a problem with I2C support and want to see more of what is going | 97 | a problem with I2C support and want to see more of what is going |
99 | on. | 98 | on. |
100 | 99 | ||
101 | config I2C_DEBUG_CHIP | ||
102 | bool "I2C Chip debugging messages" | ||
103 | help | ||
104 | Say Y here if you want the I2C chip drivers to produce a bunch of | ||
105 | debug messages to the system log. Select this if you are having | ||
106 | a problem with I2C support and want to see more of what is going | ||
107 | on. | ||
108 | |||
109 | endif # I2C | 100 | endif # I2C |
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index acd0250c16a0..a7d9b4be9bb3 100644 --- a/drivers/i2c/Makefile +++ b/drivers/i2c/Makefile | |||
@@ -6,7 +6,7 @@ obj-$(CONFIG_I2C_BOARDINFO) += i2c-boardinfo.o | |||
6 | obj-$(CONFIG_I2C) += i2c-core.o | 6 | obj-$(CONFIG_I2C) += i2c-core.o |
7 | obj-$(CONFIG_I2C_SMBUS) += i2c-smbus.o | 7 | obj-$(CONFIG_I2C_SMBUS) += i2c-smbus.o |
8 | obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o | 8 | obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o |
9 | obj-y += busses/ chips/ algos/ | 9 | obj-y += algos/ busses/ |
10 | 10 | ||
11 | ifeq ($(CONFIG_I2C_DEBUG_CORE),y) | 11 | ifeq ($(CONFIG_I2C_DEBUG_CORE),y) |
12 | EXTRA_CFLAGS += -DDEBUG | 12 | EXTRA_CFLAGS += -DDEBUG |
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index e25e13980af3..a39e6cff86e7 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/slab.h> | ||
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
30 | #include <linux/sched.h> | 29 | #include <linux/sched.h> |
@@ -522,6 +521,12 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, | |||
522 | int i, ret; | 521 | int i, ret; |
523 | unsigned short nak_ok; | 522 | unsigned short nak_ok; |
524 | 523 | ||
524 | if (adap->pre_xfer) { | ||
525 | ret = adap->pre_xfer(i2c_adap); | ||
526 | if (ret < 0) | ||
527 | return ret; | ||
528 | } | ||
529 | |||
525 | bit_dbg(3, &i2c_adap->dev, "emitting start condition\n"); | 530 | bit_dbg(3, &i2c_adap->dev, "emitting start condition\n"); |
526 | i2c_start(adap); | 531 | i2c_start(adap); |
527 | for (i = 0; i < num; i++) { | 532 | for (i = 0; i < num; i++) { |
@@ -570,6 +575,9 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, | |||
570 | bailout: | 575 | bailout: |
571 | bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n"); | 576 | bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n"); |
572 | i2c_stop(adap); | 577 | i2c_stop(adap); |
578 | |||
579 | if (adap->post_xfer) | ||
580 | adap->post_xfer(i2c_adap); | ||
573 | return ret; | 581 | return ret; |
574 | } | 582 | } |
575 | 583 | ||
diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c index 6b6bd06202b2..5eebf562ff31 100644 --- a/drivers/i2c/algos/i2c-algo-pcf.c +++ b/drivers/i2c/algos/i2c-algo-pcf.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/slab.h> | ||
33 | #include <linux/init.h> | 32 | #include <linux/init.h> |
34 | #include <linux/errno.h> | 33 | #include <linux/errno.h> |
35 | #include <linux/i2c.h> | 34 | #include <linux/i2c.h> |
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index d0dc970d7370..2fbef27b6cd6 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/acpi.h> | 19 | #include <linux/acpi.h> |
20 | #include <linux/slab.h> | ||
20 | #include <asm/io.h> | 21 | #include <asm/io.h> |
21 | 22 | ||
22 | MODULE_LICENSE("GPL"); | 23 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c index fe3fb567317d..f1e14dd590c9 100644 --- a/drivers/i2c/busses/i2c-bfin-twi.c +++ b/drivers/i2c/busses/i2c-bfin-twi.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/i2c.h> | 14 | #include <linux/i2c.h> |
15 | #include <linux/slab.h> | ||
15 | #include <linux/io.h> | 16 | #include <linux/io.h> |
16 | #include <linux/mm.h> | 17 | #include <linux/mm.h> |
17 | #include <linux/timer.h> | 18 | #include <linux/timer.h> |
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c index c89687a10835..4523364e6722 100644 --- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/interrupt.h> | 35 | #include <linux/interrupt.h> |
36 | #include <linux/platform_device.h> | 36 | #include <linux/platform_device.h> |
37 | #include <linux/io.h> | 37 | #include <linux/io.h> |
38 | #include <linux/slab.h> | ||
38 | 39 | ||
39 | #include <mach/hardware.h> | 40 | #include <mach/hardware.h> |
40 | 41 | ||
diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c index 3e72b69aa7f8..b664ed8bbdb3 100644 --- a/drivers/i2c/busses/i2c-designware.c +++ b/drivers/i2c/busses/i2c-designware.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/interrupt.h> | 36 | #include <linux/interrupt.h> |
37 | #include <linux/platform_device.h> | 37 | #include <linux/platform_device.h> |
38 | #include <linux/io.h> | 38 | #include <linux/io.h> |
39 | #include <linux/slab.h> | ||
39 | 40 | ||
40 | /* | 41 | /* |
41 | * Registers offset | 42 | * Registers offset |
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c index 448b4bf35eb7..612255614a66 100644 --- a/drivers/i2c/busses/i2c-elektor.c +++ b/drivers/i2c/busses/i2c-elektor.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/ioport.h> | 29 | #include <linux/ioport.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/slab.h> | ||
33 | #include <linux/init.h> | 32 | #include <linux/init.h> |
34 | #include <linux/interrupt.h> | 33 | #include <linux/interrupt.h> |
35 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index 32104eac8d3d..c21077d248af 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/i2c-gpio.h> | 12 | #include <linux/i2c-gpio.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/slab.h> | ||
15 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
16 | 17 | ||
17 | #include <asm/gpio.h> | 18 | #include <asm/gpio.h> |
diff --git a/drivers/i2c/busses/i2c-highlander.c b/drivers/i2c/busses/i2c-highlander.c index 87ecace415da..ce87a902c94d 100644 --- a/drivers/i2c/busses/i2c-highlander.c +++ b/drivers/i2c/busses/i2c-highlander.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/completion.h> | 19 | #include <linux/completion.h> |
20 | #include <linux/io.h> | 20 | #include <linux/io.h> |
21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
22 | #include <linux/slab.h> | ||
22 | 23 | ||
23 | #define SMCR 0x00 | 24 | #define SMCR 0x00 |
24 | #define SMCR_START (1 << 0) | 25 | #define SMCR_START (1 << 0) |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 9da5b05cdb52..299b918455a3 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -416,9 +416,11 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write, | |||
416 | data->block[0] = 32; /* max for SMBus block reads */ | 416 | data->block[0] = 32; /* max for SMBus block reads */ |
417 | } | 417 | } |
418 | 418 | ||
419 | /* Experience has shown that the block buffer can only be used for | ||
420 | SMBus (not I2C) block transactions, even though the datasheet | ||
421 | doesn't mention this limitation. */ | ||
419 | if ((i801_features & FEATURE_BLOCK_BUFFER) | 422 | if ((i801_features & FEATURE_BLOCK_BUFFER) |
420 | && !(command == I2C_SMBUS_I2C_BLOCK_DATA | 423 | && command != I2C_SMBUS_I2C_BLOCK_DATA |
421 | && read_write == I2C_SMBUS_READ) | ||
422 | && i801_set_block_buffer_mode() == 0) | 424 | && i801_set_block_buffer_mode() == 0) |
423 | result = i801_block_transaction_by_block(data, read_write, | 425 | result = i801_block_transaction_by_block(data, read_write, |
424 | hwpec); | 426 | hwpec); |
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 32375bddae7d..d1ff9408dc1f 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/sched.h> | 47 | #include <linux/sched.h> |
48 | #include <linux/platform_device.h> | 48 | #include <linux/platform_device.h> |
49 | #include <linux/clk.h> | 49 | #include <linux/clk.h> |
50 | #include <linux/slab.h> | ||
50 | 51 | ||
51 | #include <mach/irqs.h> | 52 | #include <mach/irqs.h> |
52 | #include <mach/hardware.h> | 53 | #include <mach/hardware.h> |
@@ -145,10 +146,10 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy) | |||
145 | "<%s> I2C Interrupted\n", __func__); | 146 | "<%s> I2C Interrupted\n", __func__); |
146 | return -EINTR; | 147 | return -EINTR; |
147 | } | 148 | } |
148 | if (time_after(jiffies, orig_jiffies + HZ / 1000)) { | 149 | if (time_after(jiffies, orig_jiffies + msecs_to_jiffies(500))) { |
149 | dev_dbg(&i2c_imx->adapter.dev, | 150 | dev_dbg(&i2c_imx->adapter.dev, |
150 | "<%s> I2C bus is busy\n", __func__); | 151 | "<%s> I2C bus is busy\n", __func__); |
151 | return -EIO; | 152 | return -ETIMEDOUT; |
152 | } | 153 | } |
153 | schedule(); | 154 | schedule(); |
154 | } | 155 | } |
@@ -443,6 +444,8 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter, | |||
443 | result = i2c_imx_read(i2c_imx, &msgs[i]); | 444 | result = i2c_imx_read(i2c_imx, &msgs[i]); |
444 | else | 445 | else |
445 | result = i2c_imx_write(i2c_imx, &msgs[i]); | 446 | result = i2c_imx_write(i2c_imx, &msgs[i]); |
447 | if (result) | ||
448 | goto fail0; | ||
446 | } | 449 | } |
447 | 450 | ||
448 | fail0: | 451 | fail0: |
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c index c016f7a2c5fc..5d8aed5ec21b 100644 --- a/drivers/i2c/busses/i2c-ixp2000.c +++ b/drivers/i2c/busses/i2c-ixp2000.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <linux/i2c-algo-bit.h> | 34 | #include <linux/i2c-algo-bit.h> |
35 | #include <linux/slab.h> | ||
35 | 36 | ||
36 | #include <mach/hardware.h> /* Pick up IXP2000-specific bits */ | 37 | #include <mach/hardware.h> /* Pick up IXP2000-specific bits */ |
37 | #include <mach/gpio.h> | 38 | #include <mach/gpio.h> |
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 78a15af32942..f1321f763789 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/of_platform.h> | 20 | #include <linux/of_platform.h> |
21 | #include <linux/of_i2c.h> | 21 | #include <linux/of_i2c.h> |
22 | #include <linux/slab.h> | ||
22 | 23 | ||
23 | #include <linux/io.h> | 24 | #include <linux/io.h> |
24 | #include <linux/fsl_devices.h> | 25 | #include <linux/fsl_devices.h> |
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index ed387ffa4730..3623a4499084 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c | |||
@@ -10,6 +10,7 @@ | |||
10 | * or implied. | 10 | * or implied. |
11 | */ | 11 | */ |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/slab.h> | ||
13 | #include <linux/module.h> | 14 | #include <linux/module.h> |
14 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
15 | #include <linux/i2c.h> | 16 | #include <linux/i2c.h> |
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index 4a700587ef18..4a48dd4ef787 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include <linux/delay.h> | 56 | #include <linux/delay.h> |
57 | #include <linux/dmi.h> | 57 | #include <linux/dmi.h> |
58 | #include <linux/acpi.h> | 58 | #include <linux/acpi.h> |
59 | #include <linux/slab.h> | ||
59 | #include <asm/io.h> | 60 | #include <asm/io.h> |
60 | 61 | ||
61 | MODULE_LICENSE("GPL"); | 62 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index a15f731fa451..a4f8d33fa389 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/slab.h> | ||
19 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
20 | #include <linux/i2c.h> | 21 | #include <linux/i2c.h> |
21 | #include <linux/err.h> | 22 | #include <linux/err.h> |
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c index 0dabe643ec51..b4ed4ca802ed 100644 --- a/drivers/i2c/busses/i2c-ocores.c +++ b/drivers/i2c/busses/i2c-ocores.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/wait.h> | 19 | #include <linux/wait.h> |
20 | #include <linux/i2c-ocores.h> | 20 | #include <linux/i2c-ocores.h> |
21 | #include <linux/slab.h> | ||
21 | #include <asm/io.h> | 22 | #include <asm/io.h> |
22 | 23 | ||
23 | struct ocores_i2c { | 24 | struct ocores_i2c { |
diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c index 60375504fa49..a2481f40ea1c 100644 --- a/drivers/i2c/busses/i2c-octeon.c +++ b/drivers/i2c/busses/i2c-octeon.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <linux/slab.h> | ||
17 | #include <linux/init.h> | 18 | #include <linux/init.h> |
18 | 19 | ||
19 | #include <linux/io.h> | 20 | #include <linux/io.h> |
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index c7c237537f81..389ac6032a7b 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/platform_device.h> | 37 | #include <linux/platform_device.h> |
38 | #include <linux/clk.h> | 38 | #include <linux/clk.h> |
39 | #include <linux/io.h> | 39 | #include <linux/io.h> |
40 | #include <linux/slab.h> | ||
40 | 41 | ||
41 | /* I2C controller revisions */ | 42 | /* I2C controller revisions */ |
42 | #define OMAP_I2C_REV_2 0x20 | 43 | #define OMAP_I2C_REV_2 0x20 |
@@ -902,6 +903,11 @@ omap_i2c_probe(struct platform_device *pdev) | |||
902 | 903 | ||
903 | platform_set_drvdata(pdev, dev); | 904 | platform_set_drvdata(pdev, dev); |
904 | 905 | ||
906 | if (cpu_is_omap7xx()) | ||
907 | dev->reg_shift = 1; | ||
908 | else | ||
909 | dev->reg_shift = 2; | ||
910 | |||
905 | if ((r = omap_i2c_get_clocks(dev)) != 0) | 911 | if ((r = omap_i2c_get_clocks(dev)) != 0) |
906 | goto err_iounmap; | 912 | goto err_iounmap; |
907 | 913 | ||
@@ -925,11 +931,6 @@ omap_i2c_probe(struct platform_device *pdev) | |||
925 | dev->b_hw = 1; /* Enable hardware fixes */ | 931 | dev->b_hw = 1; /* Enable hardware fixes */ |
926 | } | 932 | } |
927 | 933 | ||
928 | if (cpu_is_omap7xx()) | ||
929 | dev->reg_shift = 1; | ||
930 | else | ||
931 | dev->reg_shift = 2; | ||
932 | |||
933 | /* reset ASAP, clearing any IRQs */ | 934 | /* reset ASAP, clearing any IRQs */ |
934 | omap_i2c_init(dev); | 935 | omap_i2c_init(dev); |
935 | 936 | ||
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index 220fca7f23a6..846583ed4763 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/i2c.h> | 32 | #include <linux/i2c.h> |
33 | #include <linux/i2c-algo-bit.h> | 33 | #include <linux/i2c-algo-bit.h> |
34 | #include <linux/i2c-smbus.h> | 34 | #include <linux/i2c-smbus.h> |
35 | #include <linux/slab.h> | ||
35 | #include "i2c-parport.h" | 36 | #include "i2c-parport.h" |
36 | 37 | ||
37 | /* ----- Device list ------------------------------------------------------ */ | 38 | /* ----- Device list ------------------------------------------------------ */ |
diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c index 0d20ff46a518..d3d4a4b43a1d 100644 --- a/drivers/i2c/busses/i2c-pasemi.c +++ b/drivers/i2c/busses/i2c-pasemi.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/sched.h> | 24 | #include <linux/sched.h> |
25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/slab.h> | ||
27 | #include <asm/io.h> | 28 | #include <asm/io.h> |
28 | 29 | ||
29 | static struct pci_driver pasemi_smb_driver; | 30 | static struct pci_driver pasemi_smb_driver; |
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c index 9532dee6b580..a97e3fec8148 100644 --- a/drivers/i2c/busses/i2c-pnx.c +++ b/drivers/i2c/busses/i2c-pnx.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | #include <linux/err.h> | 23 | #include <linux/err.h> |
24 | #include <linux/clk.h> | 24 | #include <linux/clk.h> |
25 | #include <linux/slab.h> | ||
25 | 26 | ||
26 | #include <mach/hardware.h> | 27 | #include <mach/hardware.h> |
27 | #include <mach/i2c.h> | 28 | #include <mach/i2c.h> |
@@ -172,6 +173,9 @@ static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data *alg_data) | |||
172 | /* We still have something to talk about... */ | 173 | /* We still have something to talk about... */ |
173 | val = *alg_data->mif.buf++; | 174 | val = *alg_data->mif.buf++; |
174 | 175 | ||
176 | if (alg_data->mif.len == 1) | ||
177 | val |= stop_bit; | ||
178 | |||
175 | alg_data->mif.len--; | 179 | alg_data->mif.len--; |
176 | iowrite32(val, I2C_REG_TX(alg_data)); | 180 | iowrite32(val, I2C_REG_TX(alg_data)); |
177 | 181 | ||
@@ -245,6 +249,9 @@ static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data *alg_data) | |||
245 | __func__); | 249 | __func__); |
246 | 250 | ||
247 | if (alg_data->mif.len == 1) { | 251 | if (alg_data->mif.len == 1) { |
252 | /* Last byte, do not acknowledge next rcv. */ | ||
253 | val |= stop_bit; | ||
254 | |||
248 | /* | 255 | /* |
249 | * Enable interrupt RFDAIE (data in Rx fifo), | 256 | * Enable interrupt RFDAIE (data in Rx fifo), |
250 | * and disable DRMIE (need data for Tx) | 257 | * and disable DRMIE (need data for Tx) |
@@ -632,6 +639,8 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
632 | */ | 639 | */ |
633 | 640 | ||
634 | tmp = ((freq / 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2; | 641 | tmp = ((freq / 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2; |
642 | if (tmp > 0x3FF) | ||
643 | tmp = 0x3FF; | ||
635 | iowrite32(tmp, I2C_REG_CKH(alg_data)); | 644 | iowrite32(tmp, I2C_REG_CKH(alg_data)); |
636 | iowrite32(tmp, I2C_REG_CKL(alg_data)); | 645 | iowrite32(tmp, I2C_REG_CKL(alg_data)); |
637 | 646 | ||
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c index 1c440a70ec61..b289ec99eeba 100644 --- a/drivers/i2c/busses/i2c-powermac.c +++ b/drivers/i2c/busses/i2c-powermac.c | |||
@@ -122,9 +122,14 @@ static s32 i2c_powermac_smbus_xfer( struct i2c_adapter* adap, | |||
122 | 122 | ||
123 | rc = pmac_i2c_xfer(bus, addrdir, subsize, subaddr, buf, len); | 123 | rc = pmac_i2c_xfer(bus, addrdir, subsize, subaddr, buf, len); |
124 | if (rc) { | 124 | if (rc) { |
125 | dev_err(&adap->dev, | 125 | if (rc == -ENXIO) |
126 | "I2C transfer at 0x%02x failed, size %d, err %d\n", | 126 | dev_dbg(&adap->dev, |
127 | addrdir >> 1, size, rc); | 127 | "I2C transfer at 0x%02x failed, size %d, " |
128 | "err %d\n", addrdir >> 1, size, rc); | ||
129 | else | ||
130 | dev_err(&adap->dev, | ||
131 | "I2C transfer at 0x%02x failed, size %d, " | ||
132 | "err %d\n", addrdir >> 1, size, rc); | ||
128 | goto bail; | 133 | goto bail; |
129 | } | 134 | } |
130 | 135 | ||
@@ -175,10 +180,16 @@ static int i2c_powermac_master_xfer( struct i2c_adapter *adap, | |||
175 | goto bail; | 180 | goto bail; |
176 | } | 181 | } |
177 | rc = pmac_i2c_xfer(bus, addrdir, 0, 0, msgs->buf, msgs->len); | 182 | rc = pmac_i2c_xfer(bus, addrdir, 0, 0, msgs->buf, msgs->len); |
178 | if (rc < 0) | 183 | if (rc < 0) { |
179 | dev_err(&adap->dev, "I2C %s 0x%02x failed, err %d\n", | 184 | if (rc == -ENXIO) |
180 | addrdir & 1 ? "read from" : "write to", addrdir >> 1, | 185 | dev_dbg(&adap->dev, "I2C %s 0x%02x failed, err %d\n", |
181 | rc); | 186 | addrdir & 1 ? "read from" : "write to", |
187 | addrdir >> 1, rc); | ||
188 | else | ||
189 | dev_err(&adap->dev, "I2C %s 0x%02x failed, err %d\n", | ||
190 | addrdir & 1 ? "read from" : "write to", | ||
191 | addrdir >> 1, rc); | ||
192 | } | ||
182 | bail: | 193 | bail: |
183 | pmac_i2c_close(bus); | 194 | pmac_i2c_close(bus); |
184 | return rc < 0 ? rc : 1; | 195 | return rc < 0 ? rc : 1; |
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 90ffbf6f9d4f..14d249f5ed3f 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
34 | #include <linux/err.h> | 34 | #include <linux/err.h> |
35 | #include <linux/clk.h> | 35 | #include <linux/clk.h> |
36 | #include <linux/slab.h> | ||
36 | 37 | ||
37 | #include <asm/irq.h> | 38 | #include <asm/irq.h> |
38 | #include <asm/io.h> | 39 | #include <asm/io.h> |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 1d8c98613fa0..d27072b2249f 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/platform_device.h> | 34 | #include <linux/platform_device.h> |
35 | #include <linux/clk.h> | 35 | #include <linux/clk.h> |
36 | #include <linux/cpufreq.h> | 36 | #include <linux/cpufreq.h> |
37 | #include <linux/slab.h> | ||
37 | 38 | ||
38 | #include <asm/irq.h> | 39 | #include <asm/irq.h> |
39 | #include <asm/io.h> | 40 | #include <asm/io.h> |
diff --git a/drivers/i2c/busses/i2c-scmi.c b/drivers/i2c/busses/i2c-scmi.c index 365e0becaf12..388cbdc96db7 100644 --- a/drivers/i2c/busses/i2c-scmi.c +++ b/drivers/i2c/busses/i2c-scmi.c | |||
@@ -33,6 +33,7 @@ struct acpi_smbus_cmi { | |||
33 | u8 cap_info:1; | 33 | u8 cap_info:1; |
34 | u8 cap_read:1; | 34 | u8 cap_read:1; |
35 | u8 cap_write:1; | 35 | u8 cap_write:1; |
36 | struct smbus_methods_t *methods; | ||
36 | }; | 37 | }; |
37 | 38 | ||
38 | static const struct smbus_methods_t smbus_methods = { | 39 | static const struct smbus_methods_t smbus_methods = { |
@@ -41,10 +42,19 @@ static const struct smbus_methods_t smbus_methods = { | |||
41 | .mt_sbw = "_SBW", | 42 | .mt_sbw = "_SBW", |
42 | }; | 43 | }; |
43 | 44 | ||
45 | /* Some IBM BIOSes omit the leading underscore */ | ||
46 | static const struct smbus_methods_t ibm_smbus_methods = { | ||
47 | .mt_info = "SBI_", | ||
48 | .mt_sbr = "SBR_", | ||
49 | .mt_sbw = "SBW_", | ||
50 | }; | ||
51 | |||
44 | static const struct acpi_device_id acpi_smbus_cmi_ids[] = { | 52 | static const struct acpi_device_id acpi_smbus_cmi_ids[] = { |
45 | {"SMBUS01", 0}, | 53 | {"SMBUS01", (kernel_ulong_t)&smbus_methods}, |
54 | {ACPI_SMBUS_IBM_HID, (kernel_ulong_t)&ibm_smbus_methods}, | ||
46 | {"", 0} | 55 | {"", 0} |
47 | }; | 56 | }; |
57 | MODULE_DEVICE_TABLE(acpi, acpi_smbus_cmi_ids); | ||
48 | 58 | ||
49 | #define ACPI_SMBUS_STATUS_OK 0x00 | 59 | #define ACPI_SMBUS_STATUS_OK 0x00 |
50 | #define ACPI_SMBUS_STATUS_FAIL 0x07 | 60 | #define ACPI_SMBUS_STATUS_FAIL 0x07 |
@@ -150,11 +160,11 @@ acpi_smbus_cmi_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, | |||
150 | 160 | ||
151 | if (read_write == I2C_SMBUS_READ) { | 161 | if (read_write == I2C_SMBUS_READ) { |
152 | protocol |= ACPI_SMBUS_PRTCL_READ; | 162 | protocol |= ACPI_SMBUS_PRTCL_READ; |
153 | method = smbus_methods.mt_sbr; | 163 | method = smbus_cmi->methods->mt_sbr; |
154 | input.count = 3; | 164 | input.count = 3; |
155 | } else { | 165 | } else { |
156 | protocol |= ACPI_SMBUS_PRTCL_WRITE; | 166 | protocol |= ACPI_SMBUS_PRTCL_WRITE; |
157 | method = smbus_methods.mt_sbw; | 167 | method = smbus_cmi->methods->mt_sbw; |
158 | input.count = 5; | 168 | input.count = 5; |
159 | } | 169 | } |
160 | 170 | ||
@@ -290,13 +300,13 @@ static int acpi_smbus_cmi_add_cap(struct acpi_smbus_cmi *smbus_cmi, | |||
290 | union acpi_object *obj; | 300 | union acpi_object *obj; |
291 | acpi_status status; | 301 | acpi_status status; |
292 | 302 | ||
293 | if (!strcmp(name, smbus_methods.mt_info)) { | 303 | if (!strcmp(name, smbus_cmi->methods->mt_info)) { |
294 | status = acpi_evaluate_object(smbus_cmi->handle, | 304 | status = acpi_evaluate_object(smbus_cmi->handle, |
295 | smbus_methods.mt_info, | 305 | smbus_cmi->methods->mt_info, |
296 | NULL, &buffer); | 306 | NULL, &buffer); |
297 | if (ACPI_FAILURE(status)) { | 307 | if (ACPI_FAILURE(status)) { |
298 | ACPI_ERROR((AE_INFO, "Evaluating %s: %i", | 308 | ACPI_ERROR((AE_INFO, "Evaluating %s: %i", |
299 | smbus_methods.mt_info, status)); | 309 | smbus_cmi->methods->mt_info, status)); |
300 | return -EIO; | 310 | return -EIO; |
301 | } | 311 | } |
302 | 312 | ||
@@ -319,9 +329,9 @@ static int acpi_smbus_cmi_add_cap(struct acpi_smbus_cmi *smbus_cmi, | |||
319 | 329 | ||
320 | kfree(buffer.pointer); | 330 | kfree(buffer.pointer); |
321 | smbus_cmi->cap_info = 1; | 331 | smbus_cmi->cap_info = 1; |
322 | } else if (!strcmp(name, smbus_methods.mt_sbr)) | 332 | } else if (!strcmp(name, smbus_cmi->methods->mt_sbr)) |
323 | smbus_cmi->cap_read = 1; | 333 | smbus_cmi->cap_read = 1; |
324 | else if (!strcmp(name, smbus_methods.mt_sbw)) | 334 | else if (!strcmp(name, smbus_cmi->methods->mt_sbw)) |
325 | smbus_cmi->cap_write = 1; | 335 | smbus_cmi->cap_write = 1; |
326 | else | 336 | else |
327 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unsupported CMI method: %s\n", | 337 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unsupported CMI method: %s\n", |
@@ -349,6 +359,7 @@ static acpi_status acpi_smbus_cmi_query_methods(acpi_handle handle, u32 level, | |||
349 | static int acpi_smbus_cmi_add(struct acpi_device *device) | 359 | static int acpi_smbus_cmi_add(struct acpi_device *device) |
350 | { | 360 | { |
351 | struct acpi_smbus_cmi *smbus_cmi; | 361 | struct acpi_smbus_cmi *smbus_cmi; |
362 | const struct acpi_device_id *id; | ||
352 | 363 | ||
353 | smbus_cmi = kzalloc(sizeof(struct acpi_smbus_cmi), GFP_KERNEL); | 364 | smbus_cmi = kzalloc(sizeof(struct acpi_smbus_cmi), GFP_KERNEL); |
354 | if (!smbus_cmi) | 365 | if (!smbus_cmi) |
@@ -362,6 +373,11 @@ static int acpi_smbus_cmi_add(struct acpi_device *device) | |||
362 | smbus_cmi->cap_read = 0; | 373 | smbus_cmi->cap_read = 0; |
363 | smbus_cmi->cap_write = 0; | 374 | smbus_cmi->cap_write = 0; |
364 | 375 | ||
376 | for (id = acpi_smbus_cmi_ids; id->id[0]; id++) | ||
377 | if (!strcmp(id->id, acpi_device_hid(device))) | ||
378 | smbus_cmi->methods = | ||
379 | (struct smbus_methods_t *) id->driver_data; | ||
380 | |||
365 | acpi_walk_namespace(ACPI_TYPE_METHOD, smbus_cmi->handle, 1, | 381 | acpi_walk_namespace(ACPI_TYPE_METHOD, smbus_cmi->handle, 1, |
366 | acpi_smbus_cmi_query_methods, NULL, smbus_cmi, NULL); | 382 | acpi_smbus_cmi_query_methods, NULL, smbus_cmi, NULL); |
367 | 383 | ||
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index ccc46418ef7f..ffb405d7c6f2 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/pm_runtime.h> | 31 | #include <linux/pm_runtime.h> |
32 | #include <linux/clk.h> | 32 | #include <linux/clk.h> |
33 | #include <linux/io.h> | 33 | #include <linux/io.h> |
34 | #include <linux/slab.h> | ||
34 | 35 | ||
35 | /* Transmit operation: */ | 36 | /* Transmit operation: */ |
36 | /* */ | 37 | /* */ |
diff --git a/drivers/i2c/busses/i2c-simtec.c b/drivers/i2c/busses/i2c-simtec.c index 6407f47bda82..78b06107342c 100644 --- a/drivers/i2c/busses/i2c-simtec.c +++ b/drivers/i2c/busses/i2c-simtec.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
25 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/slab.h> | ||
26 | 27 | ||
27 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
28 | #include <linux/i2c-algo-bit.h> | 29 | #include <linux/i2c-algo-bit.h> |
diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c index d2728a28a8db..495be451d326 100644 --- a/drivers/i2c/busses/i2c-stu300.c +++ b/drivers/i2c/busses/i2c-stu300.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
17 | #include <linux/clk.h> | 17 | #include <linux/clk.h> |
18 | #include <linux/io.h> | 18 | #include <linux/io.h> |
19 | #include <linux/slab.h> | ||
19 | 20 | ||
20 | /* the name of this kernel module */ | 21 | /* the name of this kernel module */ |
21 | #define NAME "stu300" | 22 | #define NAME "stu300" |
@@ -497,7 +498,7 @@ static int stu300_set_clk(struct stu300_dev *dev, unsigned long clkrate) | |||
497 | int i = 0; | 498 | int i = 0; |
498 | 499 | ||
499 | /* Locate the apropriate clock setting */ | 500 | /* Locate the apropriate clock setting */ |
500 | while (i < ARRAY_SIZE(stu300_clktable) && | 501 | while (i < ARRAY_SIZE(stu300_clktable) - 1 && |
501 | stu300_clktable[i].rate < clkrate) | 502 | stu300_clktable[i].rate < clkrate) |
502 | i++; | 503 | i++; |
503 | 504 | ||
diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c index b5b1bbf37d3c..d03b04002f0d 100644 --- a/drivers/i2c/busses/i2c-tiny-usb.c +++ b/drivers/i2c/busses/i2c-tiny-usb.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/errno.h> | 14 | #include <linux/errno.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/slab.h> | ||
16 | #include <linux/types.h> | 17 | #include <linux/types.h> |
17 | 18 | ||
18 | /* include interfaces to usb layer */ | 19 | /* include interfaces to usb layer */ |
diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c index 70de82163463..5c473833d948 100644 --- a/drivers/i2c/busses/i2c-versatile.c +++ b/drivers/i2c/busses/i2c-versatile.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/i2c-algo-bit.h> | 14 | #include <linux/i2c-algo-bit.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/slab.h> | ||
17 | 18 | ||
18 | #include <asm/io.h> | 19 | #include <asm/io.h> |
19 | 20 | ||
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index eece39a5a30e..a9c419e075a5 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c | |||
@@ -32,12 +32,14 @@ | |||
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/init.h> | 33 | #include <linux/init.h> |
34 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
35 | #include <linux/delay.h> | ||
35 | #include <linux/platform_device.h> | 36 | #include <linux/platform_device.h> |
36 | #include <linux/i2c.h> | 37 | #include <linux/i2c.h> |
37 | #include <linux/interrupt.h> | 38 | #include <linux/interrupt.h> |
38 | #include <linux/wait.h> | 39 | #include <linux/wait.h> |
39 | #include <linux/i2c-xiic.h> | 40 | #include <linux/i2c-xiic.h> |
40 | #include <linux/io.h> | 41 | #include <linux/io.h> |
42 | #include <linux/slab.h> | ||
41 | 43 | ||
42 | #define DRIVER_NAME "xiic-i2c" | 44 | #define DRIVER_NAME "xiic-i2c" |
43 | 45 | ||
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index cf994bd01d9c..684395b6f3e2 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
33 | #include <linux/mutex.h> | 33 | #include <linux/mutex.h> |
34 | #include <linux/slab.h> | ||
34 | #include <asm/io.h> | 35 | #include <asm/io.h> |
35 | 36 | ||
36 | #include <linux/scx200.h> | 37 | #include <linux/scx200.h> |
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig deleted file mode 100644 index ae4539d99bef..000000000000 --- a/drivers/i2c/chips/Kconfig +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | # | ||
2 | # Miscellaneous I2C chip drivers configuration | ||
3 | # | ||
4 | # *** DEPRECATED! Do not add new entries! See Makefile *** | ||
5 | # | ||
6 | |||
7 | menu "Miscellaneous I2C Chip support" | ||
8 | |||
9 | config SENSORS_TSL2550 | ||
10 | tristate "Taos TSL2550 ambient light sensor" | ||
11 | depends on EXPERIMENTAL | ||
12 | help | ||
13 | If you say yes here you get support for the Taos TSL2550 | ||
14 | ambient light sensor. | ||
15 | |||
16 | This driver can also be built as a module. If so, the module | ||
17 | will be called tsl2550. | ||
18 | |||
19 | endmenu | ||
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile deleted file mode 100644 index fe0af0f81f2d..000000000000 --- a/drivers/i2c/chips/Makefile +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | # | ||
2 | # Makefile for miscellaneous I2C chip drivers. | ||
3 | # | ||
4 | # Do not add new drivers to this directory! It is DEPRECATED. | ||
5 | # | ||
6 | # Device drivers are better grouped according to the functionality they | ||
7 | # implement rather than to the bus they are connected to. In particular: | ||
8 | # * Hardware monitoring chip drivers go to drivers/hwmon | ||
9 | # * RTC chip drivers go to drivers/rtc | ||
10 | # * I/O expander drivers go to drivers/gpio | ||
11 | # | ||
12 | |||
13 | obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o | ||
14 | |||
15 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) | ||
16 | EXTRA_CFLAGS += -DDEBUG | ||
17 | endif | ||
18 | |||
diff --git a/drivers/i2c/chips/tsl2550.c b/drivers/i2c/chips/tsl2550.c deleted file mode 100644 index a0702f36a72f..000000000000 --- a/drivers/i2c/chips/tsl2550.c +++ /dev/null | |||
@@ -1,473 +0,0 @@ | |||
1 | /* | ||
2 | * tsl2550.c - Linux kernel modules for ambient light sensor | ||
3 | * | ||
4 | * Copyright (C) 2007 Rodolfo Giometti <giometti@linux.it> | ||
5 | * Copyright (C) 2007 Eurotech S.p.A. <info@eurotech.it> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/slab.h> | ||
25 | #include <linux/i2c.h> | ||
26 | #include <linux/mutex.h> | ||
27 | |||
28 | #define TSL2550_DRV_NAME "tsl2550" | ||
29 | #define DRIVER_VERSION "1.2" | ||
30 | |||
31 | /* | ||
32 | * Defines | ||
33 | */ | ||
34 | |||
35 | #define TSL2550_POWER_DOWN 0x00 | ||
36 | #define TSL2550_POWER_UP 0x03 | ||
37 | #define TSL2550_STANDARD_RANGE 0x18 | ||
38 | #define TSL2550_EXTENDED_RANGE 0x1d | ||
39 | #define TSL2550_READ_ADC0 0x43 | ||
40 | #define TSL2550_READ_ADC1 0x83 | ||
41 | |||
42 | /* | ||
43 | * Structs | ||
44 | */ | ||
45 | |||
46 | struct tsl2550_data { | ||
47 | struct i2c_client *client; | ||
48 | struct mutex update_lock; | ||
49 | |||
50 | unsigned int power_state : 1; | ||
51 | unsigned int operating_mode : 1; | ||
52 | }; | ||
53 | |||
54 | /* | ||
55 | * Global data | ||
56 | */ | ||
57 | |||
58 | static const u8 TSL2550_MODE_RANGE[2] = { | ||
59 | TSL2550_STANDARD_RANGE, TSL2550_EXTENDED_RANGE, | ||
60 | }; | ||
61 | |||
62 | /* | ||
63 | * Management functions | ||
64 | */ | ||
65 | |||
66 | static int tsl2550_set_operating_mode(struct i2c_client *client, int mode) | ||
67 | { | ||
68 | struct tsl2550_data *data = i2c_get_clientdata(client); | ||
69 | |||
70 | int ret = i2c_smbus_write_byte(client, TSL2550_MODE_RANGE[mode]); | ||
71 | |||
72 | data->operating_mode = mode; | ||
73 | |||
74 | return ret; | ||
75 | } | ||
76 | |||
77 | static int tsl2550_set_power_state(struct i2c_client *client, int state) | ||
78 | { | ||
79 | struct tsl2550_data *data = i2c_get_clientdata(client); | ||
80 | int ret; | ||
81 | |||
82 | if (state == 0) | ||
83 | ret = i2c_smbus_write_byte(client, TSL2550_POWER_DOWN); | ||
84 | else { | ||
85 | ret = i2c_smbus_write_byte(client, TSL2550_POWER_UP); | ||
86 | |||
87 | /* On power up we should reset operating mode also... */ | ||
88 | tsl2550_set_operating_mode(client, data->operating_mode); | ||
89 | } | ||
90 | |||
91 | data->power_state = state; | ||
92 | |||
93 | return ret; | ||
94 | } | ||
95 | |||
96 | static int tsl2550_get_adc_value(struct i2c_client *client, u8 cmd) | ||
97 | { | ||
98 | int ret; | ||
99 | |||
100 | ret = i2c_smbus_read_byte_data(client, cmd); | ||
101 | if (ret < 0) | ||
102 | return ret; | ||
103 | if (!(ret & 0x80)) | ||
104 | return -EAGAIN; | ||
105 | return ret & 0x7f; /* remove the "valid" bit */ | ||
106 | } | ||
107 | |||
108 | /* | ||
109 | * LUX calculation | ||
110 | */ | ||
111 | |||
112 | #define TSL2550_MAX_LUX 1846 | ||
113 | |||
114 | static const u8 ratio_lut[] = { | ||
115 | 100, 100, 100, 100, 100, 100, 100, 100, | ||
116 | 100, 100, 100, 100, 100, 100, 99, 99, | ||
117 | 99, 99, 99, 99, 99, 99, 99, 99, | ||
118 | 99, 99, 99, 98, 98, 98, 98, 98, | ||
119 | 98, 98, 97, 97, 97, 97, 97, 96, | ||
120 | 96, 96, 96, 95, 95, 95, 94, 94, | ||
121 | 93, 93, 93, 92, 92, 91, 91, 90, | ||
122 | 89, 89, 88, 87, 87, 86, 85, 84, | ||
123 | 83, 82, 81, 80, 79, 78, 77, 75, | ||
124 | 74, 73, 71, 69, 68, 66, 64, 62, | ||
125 | 60, 58, 56, 54, 52, 49, 47, 44, | ||
126 | 42, 41, 40, 40, 39, 39, 38, 38, | ||
127 | 37, 37, 37, 36, 36, 36, 35, 35, | ||
128 | 35, 35, 34, 34, 34, 34, 33, 33, | ||
129 | 33, 33, 32, 32, 32, 32, 32, 31, | ||
130 | 31, 31, 31, 31, 30, 30, 30, 30, | ||
131 | 30, | ||
132 | }; | ||
133 | |||
134 | static const u16 count_lut[] = { | ||
135 | 0, 1, 2, 3, 4, 5, 6, 7, | ||
136 | 8, 9, 10, 11, 12, 13, 14, 15, | ||
137 | 16, 18, 20, 22, 24, 26, 28, 30, | ||
138 | 32, 34, 36, 38, 40, 42, 44, 46, | ||
139 | 49, 53, 57, 61, 65, 69, 73, 77, | ||
140 | 81, 85, 89, 93, 97, 101, 105, 109, | ||
141 | 115, 123, 131, 139, 147, 155, 163, 171, | ||
142 | 179, 187, 195, 203, 211, 219, 227, 235, | ||
143 | 247, 263, 279, 295, 311, 327, 343, 359, | ||
144 | 375, 391, 407, 423, 439, 455, 471, 487, | ||
145 | 511, 543, 575, 607, 639, 671, 703, 735, | ||
146 | 767, 799, 831, 863, 895, 927, 959, 991, | ||
147 | 1039, 1103, 1167, 1231, 1295, 1359, 1423, 1487, | ||
148 | 1551, 1615, 1679, 1743, 1807, 1871, 1935, 1999, | ||
149 | 2095, 2223, 2351, 2479, 2607, 2735, 2863, 2991, | ||
150 | 3119, 3247, 3375, 3503, 3631, 3759, 3887, 4015, | ||
151 | }; | ||
152 | |||
153 | /* | ||
154 | * This function is described into Taos TSL2550 Designer's Notebook | ||
155 | * pages 2, 3. | ||
156 | */ | ||
157 | static int tsl2550_calculate_lux(u8 ch0, u8 ch1) | ||
158 | { | ||
159 | unsigned int lux; | ||
160 | |||
161 | /* Look up count from channel values */ | ||
162 | u16 c0 = count_lut[ch0]; | ||
163 | u16 c1 = count_lut[ch1]; | ||
164 | |||
165 | /* | ||
166 | * Calculate ratio. | ||
167 | * Note: the "128" is a scaling factor | ||
168 | */ | ||
169 | u8 r = 128; | ||
170 | |||
171 | /* Avoid division by 0 and count 1 cannot be greater than count 0 */ | ||
172 | if (c1 <= c0) | ||
173 | if (c0) { | ||
174 | r = c1 * 128 / c0; | ||
175 | |||
176 | /* Calculate LUX */ | ||
177 | lux = ((c0 - c1) * ratio_lut[r]) / 256; | ||
178 | } else | ||
179 | lux = 0; | ||
180 | else | ||
181 | return -EAGAIN; | ||
182 | |||
183 | /* LUX range check */ | ||
184 | return lux > TSL2550_MAX_LUX ? TSL2550_MAX_LUX : lux; | ||
185 | } | ||
186 | |||
187 | /* | ||
188 | * SysFS support | ||
189 | */ | ||
190 | |||
191 | static ssize_t tsl2550_show_power_state(struct device *dev, | ||
192 | struct device_attribute *attr, char *buf) | ||
193 | { | ||
194 | struct tsl2550_data *data = i2c_get_clientdata(to_i2c_client(dev)); | ||
195 | |||
196 | return sprintf(buf, "%u\n", data->power_state); | ||
197 | } | ||
198 | |||
199 | static ssize_t tsl2550_store_power_state(struct device *dev, | ||
200 | struct device_attribute *attr, const char *buf, size_t count) | ||
201 | { | ||
202 | struct i2c_client *client = to_i2c_client(dev); | ||
203 | struct tsl2550_data *data = i2c_get_clientdata(client); | ||
204 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
205 | int ret; | ||
206 | |||
207 | if (val < 0 || val > 1) | ||
208 | return -EINVAL; | ||
209 | |||
210 | mutex_lock(&data->update_lock); | ||
211 | ret = tsl2550_set_power_state(client, val); | ||
212 | mutex_unlock(&data->update_lock); | ||
213 | |||
214 | if (ret < 0) | ||
215 | return ret; | ||
216 | |||
217 | return count; | ||
218 | } | ||
219 | |||
220 | static DEVICE_ATTR(power_state, S_IWUSR | S_IRUGO, | ||
221 | tsl2550_show_power_state, tsl2550_store_power_state); | ||
222 | |||
223 | static ssize_t tsl2550_show_operating_mode(struct device *dev, | ||
224 | struct device_attribute *attr, char *buf) | ||
225 | { | ||
226 | struct tsl2550_data *data = i2c_get_clientdata(to_i2c_client(dev)); | ||
227 | |||
228 | return sprintf(buf, "%u\n", data->operating_mode); | ||
229 | } | ||
230 | |||
231 | static ssize_t tsl2550_store_operating_mode(struct device *dev, | ||
232 | struct device_attribute *attr, const char *buf, size_t count) | ||
233 | { | ||
234 | struct i2c_client *client = to_i2c_client(dev); | ||
235 | struct tsl2550_data *data = i2c_get_clientdata(client); | ||
236 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
237 | int ret; | ||
238 | |||
239 | if (val < 0 || val > 1) | ||
240 | return -EINVAL; | ||
241 | |||
242 | if (data->power_state == 0) | ||
243 | return -EBUSY; | ||
244 | |||
245 | mutex_lock(&data->update_lock); | ||
246 | ret = tsl2550_set_operating_mode(client, val); | ||
247 | mutex_unlock(&data->update_lock); | ||
248 | |||
249 | if (ret < 0) | ||
250 | return ret; | ||
251 | |||
252 | return count; | ||
253 | } | ||
254 | |||
255 | static DEVICE_ATTR(operating_mode, S_IWUSR | S_IRUGO, | ||
256 | tsl2550_show_operating_mode, tsl2550_store_operating_mode); | ||
257 | |||
258 | static ssize_t __tsl2550_show_lux(struct i2c_client *client, char *buf) | ||
259 | { | ||
260 | struct tsl2550_data *data = i2c_get_clientdata(client); | ||
261 | u8 ch0, ch1; | ||
262 | int ret; | ||
263 | |||
264 | ret = tsl2550_get_adc_value(client, TSL2550_READ_ADC0); | ||
265 | if (ret < 0) | ||
266 | return ret; | ||
267 | ch0 = ret; | ||
268 | |||
269 | ret = tsl2550_get_adc_value(client, TSL2550_READ_ADC1); | ||
270 | if (ret < 0) | ||
271 | return ret; | ||
272 | ch1 = ret; | ||
273 | |||
274 | /* Do the job */ | ||
275 | ret = tsl2550_calculate_lux(ch0, ch1); | ||
276 | if (ret < 0) | ||
277 | return ret; | ||
278 | if (data->operating_mode == 1) | ||
279 | ret *= 5; | ||
280 | |||
281 | return sprintf(buf, "%d\n", ret); | ||
282 | } | ||
283 | |||
284 | static ssize_t tsl2550_show_lux1_input(struct device *dev, | ||
285 | struct device_attribute *attr, char *buf) | ||
286 | { | ||
287 | struct i2c_client *client = to_i2c_client(dev); | ||
288 | struct tsl2550_data *data = i2c_get_clientdata(client); | ||
289 | int ret; | ||
290 | |||
291 | /* No LUX data if not operational */ | ||
292 | if (!data->power_state) | ||
293 | return -EBUSY; | ||
294 | |||
295 | mutex_lock(&data->update_lock); | ||
296 | ret = __tsl2550_show_lux(client, buf); | ||
297 | mutex_unlock(&data->update_lock); | ||
298 | |||
299 | return ret; | ||
300 | } | ||
301 | |||
302 | static DEVICE_ATTR(lux1_input, S_IRUGO, | ||
303 | tsl2550_show_lux1_input, NULL); | ||
304 | |||
305 | static struct attribute *tsl2550_attributes[] = { | ||
306 | &dev_attr_power_state.attr, | ||
307 | &dev_attr_operating_mode.attr, | ||
308 | &dev_attr_lux1_input.attr, | ||
309 | NULL | ||
310 | }; | ||
311 | |||
312 | static const struct attribute_group tsl2550_attr_group = { | ||
313 | .attrs = tsl2550_attributes, | ||
314 | }; | ||
315 | |||
316 | /* | ||
317 | * Initialization function | ||
318 | */ | ||
319 | |||
320 | static int tsl2550_init_client(struct i2c_client *client) | ||
321 | { | ||
322 | struct tsl2550_data *data = i2c_get_clientdata(client); | ||
323 | int err; | ||
324 | |||
325 | /* | ||
326 | * Probe the chip. To do so we try to power up the device and then to | ||
327 | * read back the 0x03 code | ||
328 | */ | ||
329 | err = i2c_smbus_read_byte_data(client, TSL2550_POWER_UP); | ||
330 | if (err < 0) | ||
331 | return err; | ||
332 | if (err != TSL2550_POWER_UP) | ||
333 | return -ENODEV; | ||
334 | data->power_state = 1; | ||
335 | |||
336 | /* Set the default operating mode */ | ||
337 | err = i2c_smbus_write_byte(client, | ||
338 | TSL2550_MODE_RANGE[data->operating_mode]); | ||
339 | if (err < 0) | ||
340 | return err; | ||
341 | |||
342 | return 0; | ||
343 | } | ||
344 | |||
345 | /* | ||
346 | * I2C init/probing/exit functions | ||
347 | */ | ||
348 | |||
349 | static struct i2c_driver tsl2550_driver; | ||
350 | static int __devinit tsl2550_probe(struct i2c_client *client, | ||
351 | const struct i2c_device_id *id) | ||
352 | { | ||
353 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); | ||
354 | struct tsl2550_data *data; | ||
355 | int *opmode, err = 0; | ||
356 | |||
357 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE | ||
358 | | I2C_FUNC_SMBUS_READ_BYTE_DATA)) { | ||
359 | err = -EIO; | ||
360 | goto exit; | ||
361 | } | ||
362 | |||
363 | data = kzalloc(sizeof(struct tsl2550_data), GFP_KERNEL); | ||
364 | if (!data) { | ||
365 | err = -ENOMEM; | ||
366 | goto exit; | ||
367 | } | ||
368 | data->client = client; | ||
369 | i2c_set_clientdata(client, data); | ||
370 | |||
371 | /* Check platform data */ | ||
372 | opmode = client->dev.platform_data; | ||
373 | if (opmode) { | ||
374 | if (*opmode < 0 || *opmode > 1) { | ||
375 | dev_err(&client->dev, "invalid operating_mode (%d)\n", | ||
376 | *opmode); | ||
377 | err = -EINVAL; | ||
378 | goto exit_kfree; | ||
379 | } | ||
380 | data->operating_mode = *opmode; | ||
381 | } else | ||
382 | data->operating_mode = 0; /* default mode is standard */ | ||
383 | dev_info(&client->dev, "%s operating mode\n", | ||
384 | data->operating_mode ? "extended" : "standard"); | ||
385 | |||
386 | mutex_init(&data->update_lock); | ||
387 | |||
388 | /* Initialize the TSL2550 chip */ | ||
389 | err = tsl2550_init_client(client); | ||
390 | if (err) | ||
391 | goto exit_kfree; | ||
392 | |||
393 | /* Register sysfs hooks */ | ||
394 | err = sysfs_create_group(&client->dev.kobj, &tsl2550_attr_group); | ||
395 | if (err) | ||
396 | goto exit_kfree; | ||
397 | |||
398 | dev_info(&client->dev, "support ver. %s enabled\n", DRIVER_VERSION); | ||
399 | |||
400 | return 0; | ||
401 | |||
402 | exit_kfree: | ||
403 | kfree(data); | ||
404 | exit: | ||
405 | return err; | ||
406 | } | ||
407 | |||
408 | static int __devexit tsl2550_remove(struct i2c_client *client) | ||
409 | { | ||
410 | sysfs_remove_group(&client->dev.kobj, &tsl2550_attr_group); | ||
411 | |||
412 | /* Power down the device */ | ||
413 | tsl2550_set_power_state(client, 0); | ||
414 | |||
415 | kfree(i2c_get_clientdata(client)); | ||
416 | |||
417 | return 0; | ||
418 | } | ||
419 | |||
420 | #ifdef CONFIG_PM | ||
421 | |||
422 | static int tsl2550_suspend(struct i2c_client *client, pm_message_t mesg) | ||
423 | { | ||
424 | return tsl2550_set_power_state(client, 0); | ||
425 | } | ||
426 | |||
427 | static int tsl2550_resume(struct i2c_client *client) | ||
428 | { | ||
429 | return tsl2550_set_power_state(client, 1); | ||
430 | } | ||
431 | |||
432 | #else | ||
433 | |||
434 | #define tsl2550_suspend NULL | ||
435 | #define tsl2550_resume NULL | ||
436 | |||
437 | #endif /* CONFIG_PM */ | ||
438 | |||
439 | static const struct i2c_device_id tsl2550_id[] = { | ||
440 | { "tsl2550", 0 }, | ||
441 | { } | ||
442 | }; | ||
443 | MODULE_DEVICE_TABLE(i2c, tsl2550_id); | ||
444 | |||
445 | static struct i2c_driver tsl2550_driver = { | ||
446 | .driver = { | ||
447 | .name = TSL2550_DRV_NAME, | ||
448 | .owner = THIS_MODULE, | ||
449 | }, | ||
450 | .suspend = tsl2550_suspend, | ||
451 | .resume = tsl2550_resume, | ||
452 | .probe = tsl2550_probe, | ||
453 | .remove = __devexit_p(tsl2550_remove), | ||
454 | .id_table = tsl2550_id, | ||
455 | }; | ||
456 | |||
457 | static int __init tsl2550_init(void) | ||
458 | { | ||
459 | return i2c_add_driver(&tsl2550_driver); | ||
460 | } | ||
461 | |||
462 | static void __exit tsl2550_exit(void) | ||
463 | { | ||
464 | i2c_del_driver(&tsl2550_driver); | ||
465 | } | ||
466 | |||
467 | MODULE_AUTHOR("Rodolfo Giometti <giometti@linux.it>"); | ||
468 | MODULE_DESCRIPTION("TSL2550 ambient light sensor driver"); | ||
469 | MODULE_LICENSE("GPL"); | ||
470 | MODULE_VERSION(DRIVER_VERSION); | ||
471 | |||
472 | module_init(tsl2550_init); | ||
473 | module_exit(tsl2550_exit); | ||
diff --git a/drivers/i2c/i2c-boardinfo.c b/drivers/i2c/i2c-boardinfo.c index a26a34a06641..7e6a63b57165 100644 --- a/drivers/i2c/i2c-boardinfo.c +++ b/drivers/i2c/i2c-boardinfo.c | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/i2c.h> | 20 | #include <linux/i2c.h> |
21 | #include <linux/slab.h> | ||
21 | #include <linux/rwsem.h> | 22 | #include <linux/rwsem.h> |
22 | 23 | ||
23 | #include "i2c-core.h" | 24 | #include "i2c-core.h" |
diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c index 421278221243..a24e0bfe9201 100644 --- a/drivers/i2c/i2c-smbus.c +++ b/drivers/i2c/i2c-smbus.c | |||
@@ -22,11 +22,11 @@ | |||
22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/device.h> | 24 | #include <linux/device.h> |
25 | #include <linux/semaphore.h> | ||
26 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
27 | #include <linux/workqueue.h> | 26 | #include <linux/workqueue.h> |
28 | #include <linux/i2c.h> | 27 | #include <linux/i2c.h> |
29 | #include <linux/i2c-smbus.h> | 28 | #include <linux/i2c-smbus.h> |
29 | #include <linux/slab.h> | ||
30 | 30 | ||
31 | struct i2c_smbus_alert { | 31 | struct i2c_smbus_alert { |
32 | unsigned int alert_edge_triggered:1; | 32 | unsigned int alert_edge_triggered:1; |
@@ -55,7 +55,7 @@ static int smbus_do_alert(struct device *dev, void *addrp) | |||
55 | * Drivers should either disable alerts, or provide at least | 55 | * Drivers should either disable alerts, or provide at least |
56 | * a minimal handler. Lock so client->driver won't change. | 56 | * a minimal handler. Lock so client->driver won't change. |
57 | */ | 57 | */ |
58 | down(&dev->sem); | 58 | device_lock(dev); |
59 | if (client->driver) { | 59 | if (client->driver) { |
60 | if (client->driver->alert) | 60 | if (client->driver->alert) |
61 | client->driver->alert(client, data->flag); | 61 | client->driver->alert(client, data->flag); |
@@ -63,7 +63,7 @@ static int smbus_do_alert(struct device *dev, void *addrp) | |||
63 | dev_warn(&client->dev, "no driver alert()!\n"); | 63 | dev_warn(&client->dev, "no driver alert()!\n"); |
64 | } else | 64 | } else |
65 | dev_dbg(&client->dev, "alert with no driver\n"); | 65 | dev_dbg(&client->dev, "alert with no driver\n"); |
66 | up(&dev->sem); | 66 | device_unlock(dev); |
67 | 67 | ||
68 | /* Stop iterating after we find the device */ | 68 | /* Stop iterating after we find the device */ |
69 | return -EBUSY; | 69 | return -EBUSY; |