diff options
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/Kconfig | 14 | ||||
-rw-r--r-- | drivers/i2c/algos/Kconfig | 11 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-acorn.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-amd756-s4882.c | 9 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-at91.c | 6 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-bfin-twi.c | 35 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-davinci.c | 5 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-gpio.c | 9 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-ixp2000.c | 4 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-nforce2-s4985.c | 5 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-pnx.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-pxa.c | 6 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-s3c2410.c | 133 | ||||
-rw-r--r-- | drivers/i2c/chips/Kconfig | 2 | ||||
-rw-r--r-- | drivers/i2c/chips/at24.c | 8 | ||||
-rw-r--r-- | drivers/i2c/chips/isp1301_omap.c | 6 | ||||
-rw-r--r-- | drivers/i2c/chips/menelaus.c | 5 | ||||
-rw-r--r-- | drivers/i2c/chips/tps65010.c | 2 | ||||
-rw-r--r-- | drivers/i2c/i2c-core.c | 11 | ||||
-rw-r--r-- | drivers/i2c/i2c-dev.c | 4 |
20 files changed, 210 insertions, 69 deletions
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index 96867347bcbf..711ca08ab776 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig | |||
@@ -38,6 +38,20 @@ config I2C_CHARDEV | |||
38 | This support is also available as a module. If so, the module | 38 | This support is also available as a module. If so, the module |
39 | will be called i2c-dev. | 39 | will be called i2c-dev. |
40 | 40 | ||
41 | config I2C_HELPER_AUTO | ||
42 | bool "Autoselect pertinent helper modules" | ||
43 | default y | ||
44 | help | ||
45 | Some I2C bus drivers require so-called "I2C algorithm" modules | ||
46 | to work. These are basically software-only abstractions of generic | ||
47 | I2C interfaces. This option will autoselect them so that you don't | ||
48 | have to care. | ||
49 | |||
50 | Unselect this only if you need to enable additional helper | ||
51 | modules, for example for use with external I2C bus drivers. | ||
52 | |||
53 | In doubt, say Y. | ||
54 | |||
41 | source drivers/i2c/algos/Kconfig | 55 | source drivers/i2c/algos/Kconfig |
42 | source drivers/i2c/busses/Kconfig | 56 | source drivers/i2c/busses/Kconfig |
43 | source drivers/i2c/chips/Kconfig | 57 | source drivers/i2c/chips/Kconfig |
diff --git a/drivers/i2c/algos/Kconfig b/drivers/i2c/algos/Kconfig index 7137a17402fe..b788579b8227 100644 --- a/drivers/i2c/algos/Kconfig +++ b/drivers/i2c/algos/Kconfig | |||
@@ -2,15 +2,20 @@ | |||
2 | # I2C algorithm drivers configuration | 2 | # I2C algorithm drivers configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "I2C Algorithms" | ||
6 | depends on !I2C_HELPER_AUTO | ||
7 | |||
5 | config I2C_ALGOBIT | 8 | config I2C_ALGOBIT |
6 | tristate | 9 | tristate "I2C bit-banging interfaces" |
7 | 10 | ||
8 | config I2C_ALGOPCF | 11 | config I2C_ALGOPCF |
9 | tristate | 12 | tristate "I2C PCF 8584 interfaces" |
10 | 13 | ||
11 | config I2C_ALGOPCA | 14 | config I2C_ALGOPCA |
12 | tristate | 15 | tristate "I2C PCA 9564 interfaces" |
13 | 16 | ||
14 | config I2C_ALGO_SGI | 17 | config I2C_ALGO_SGI |
15 | tristate | 18 | tristate |
16 | depends on SGI_IP22 || SGI_IP32 || X86_VISWS | 19 | depends on SGI_IP22 || SGI_IP32 || X86_VISWS |
20 | |||
21 | endmenu | ||
diff --git a/drivers/i2c/busses/i2c-acorn.c b/drivers/i2c/busses/i2c-acorn.c index 7c2be3558a24..75089febbc13 100644 --- a/drivers/i2c/busses/i2c-acorn.c +++ b/drivers/i2c/busses/i2c-acorn.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/i2c.h> | 16 | #include <linux/i2c.h> |
17 | #include <linux/i2c-algo-bit.h> | 17 | #include <linux/i2c-algo-bit.h> |
18 | 18 | ||
19 | #include <asm/hardware.h> | 19 | #include <mach/hardware.h> |
20 | #include <asm/io.h> | 20 | #include <asm/io.h> |
21 | #include <asm/hardware/ioc.h> | 21 | #include <asm/hardware/ioc.h> |
22 | #include <asm/system.h> | 22 | #include <asm/system.h> |
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c index 72872d1e63ef..8ba2bcf727d3 100644 --- a/drivers/i2c/busses/i2c-amd756-s4882.c +++ b/drivers/i2c/busses/i2c-amd756-s4882.c | |||
@@ -155,6 +155,9 @@ static int __init amd756_s4882_init(void) | |||
155 | int i, error; | 155 | int i, error; |
156 | union i2c_smbus_data ioconfig; | 156 | union i2c_smbus_data ioconfig; |
157 | 157 | ||
158 | if (!amd756_smbus.dev.parent) | ||
159 | return -ENODEV; | ||
160 | |||
158 | /* Configure the PCA9556 multiplexer */ | 161 | /* Configure the PCA9556 multiplexer */ |
159 | ioconfig.byte = 0x00; /* All I/O to output mode */ | 162 | ioconfig.byte = 0x00; /* All I/O to output mode */ |
160 | error = i2c_smbus_xfer(&amd756_smbus, 0x18, 0, I2C_SMBUS_WRITE, 0x03, | 163 | error = i2c_smbus_xfer(&amd756_smbus, 0x18, 0, I2C_SMBUS_WRITE, 0x03, |
@@ -168,11 +171,7 @@ static int __init amd756_s4882_init(void) | |||
168 | /* Unregister physical bus */ | 171 | /* Unregister physical bus */ |
169 | error = i2c_del_adapter(&amd756_smbus); | 172 | error = i2c_del_adapter(&amd756_smbus); |
170 | if (error) { | 173 | if (error) { |
171 | if (error == -EINVAL) | 174 | dev_err(&amd756_smbus.dev, "Physical bus removal failed\n"); |
172 | error = -ENODEV; | ||
173 | else | ||
174 | dev_err(&amd756_smbus.dev, "Physical bus removal " | ||
175 | "failed\n"); | ||
176 | goto ERROR0; | 175 | goto ERROR0; |
177 | } | 176 | } |
178 | 177 | ||
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index 73d61946a534..c1adcdbf7979 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c | |||
@@ -27,9 +27,9 @@ | |||
27 | 27 | ||
28 | #include <asm/io.h> | 28 | #include <asm/io.h> |
29 | 29 | ||
30 | #include <asm/arch/at91_twi.h> | 30 | #include <mach/at91_twi.h> |
31 | #include <asm/arch/board.h> | 31 | #include <mach/board.h> |
32 | #include <asm/arch/cpu.h> | 32 | #include <mach/cpu.h> |
33 | 33 | ||
34 | #define TWI_CLOCK 100000 /* Hz. max 400 Kbits/sec */ | 34 | #define TWI_CLOCK 100000 /* Hz. max 400 Kbits/sec */ |
35 | 35 | ||
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c index 48d084bdf7c8..3c855ff2992f 100644 --- a/drivers/i2c/busses/i2c-bfin-twi.c +++ b/drivers/i2c/busses/i2c-bfin-twi.c | |||
@@ -49,6 +49,8 @@ struct bfin_twi_iface { | |||
49 | struct i2c_msg *pmsg; | 49 | struct i2c_msg *pmsg; |
50 | int msg_num; | 50 | int msg_num; |
51 | int cur_msg; | 51 | int cur_msg; |
52 | u16 saved_clkdiv; | ||
53 | u16 saved_control; | ||
52 | void __iomem *regs_base; | 54 | void __iomem *regs_base; |
53 | }; | 55 | }; |
54 | 56 | ||
@@ -565,32 +567,43 @@ static u32 bfin_twi_functionality(struct i2c_adapter *adap) | |||
565 | I2C_FUNC_I2C; | 567 | I2C_FUNC_I2C; |
566 | } | 568 | } |
567 | 569 | ||
568 | |||
569 | static struct i2c_algorithm bfin_twi_algorithm = { | 570 | static struct i2c_algorithm bfin_twi_algorithm = { |
570 | .master_xfer = bfin_twi_master_xfer, | 571 | .master_xfer = bfin_twi_master_xfer, |
571 | .smbus_xfer = bfin_twi_smbus_xfer, | 572 | .smbus_xfer = bfin_twi_smbus_xfer, |
572 | .functionality = bfin_twi_functionality, | 573 | .functionality = bfin_twi_functionality, |
573 | }; | 574 | }; |
574 | 575 | ||
575 | 576 | static int i2c_bfin_twi_suspend(struct platform_device *pdev, pm_message_t state) | |
576 | static int i2c_bfin_twi_suspend(struct platform_device *dev, pm_message_t state) | ||
577 | { | 577 | { |
578 | struct bfin_twi_iface *iface = platform_get_drvdata(dev); | 578 | struct bfin_twi_iface *iface = platform_get_drvdata(pdev); |
579 | |||
580 | iface->saved_clkdiv = read_CLKDIV(iface); | ||
581 | iface->saved_control = read_CONTROL(iface); | ||
582 | |||
583 | free_irq(iface->irq, iface); | ||
579 | 584 | ||
580 | /* Disable TWI */ | 585 | /* Disable TWI */ |
581 | write_CONTROL(iface, read_CONTROL(iface) & ~TWI_ENA); | 586 | write_CONTROL(iface, iface->saved_control & ~TWI_ENA); |
582 | SSYNC(); | ||
583 | 587 | ||
584 | return 0; | 588 | return 0; |
585 | } | 589 | } |
586 | 590 | ||
587 | static int i2c_bfin_twi_resume(struct platform_device *dev) | 591 | static int i2c_bfin_twi_resume(struct platform_device *pdev) |
588 | { | 592 | { |
589 | struct bfin_twi_iface *iface = platform_get_drvdata(dev); | 593 | struct bfin_twi_iface *iface = platform_get_drvdata(pdev); |
590 | 594 | ||
591 | /* Enable TWI */ | 595 | int rc = request_irq(iface->irq, bfin_twi_interrupt_entry, |
592 | write_CONTROL(iface, read_CONTROL(iface) | TWI_ENA); | 596 | IRQF_DISABLED, pdev->name, iface); |
593 | SSYNC(); | 597 | if (rc) { |
598 | dev_err(&pdev->dev, "Can't get IRQ %d !\n", iface->irq); | ||
599 | return -ENODEV; | ||
600 | } | ||
601 | |||
602 | /* Resume TWI interface clock as specified */ | ||
603 | write_CLKDIV(iface, iface->saved_clkdiv); | ||
604 | |||
605 | /* Resume TWI */ | ||
606 | write_CONTROL(iface, iface->saved_control); | ||
594 | 607 | ||
595 | return 0; | 608 | return 0; |
596 | } | 609 | } |
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c index af3846eda985..5d7789834b95 100644 --- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c | |||
@@ -36,10 +36,9 @@ | |||
36 | #include <linux/platform_device.h> | 36 | #include <linux/platform_device.h> |
37 | #include <linux/io.h> | 37 | #include <linux/io.h> |
38 | 38 | ||
39 | #include <asm/hardware.h> | 39 | #include <mach/hardware.h> |
40 | #include <asm/mach-types.h> | ||
41 | 40 | ||
42 | #include <asm/arch/i2c.h> | 41 | #include <mach/i2c.h> |
43 | 42 | ||
44 | /* ----- global defines ----------------------------------------------- */ | 43 | /* ----- global defines ----------------------------------------------- */ |
45 | 44 | ||
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index 79b455a1f090..32104eac8d3d 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c | |||
@@ -77,7 +77,7 @@ static int i2c_gpio_getscl(void *data) | |||
77 | return gpio_get_value(pdata->scl_pin); | 77 | return gpio_get_value(pdata->scl_pin); |
78 | } | 78 | } |
79 | 79 | ||
80 | static int __init i2c_gpio_probe(struct platform_device *pdev) | 80 | static int __devinit i2c_gpio_probe(struct platform_device *pdev) |
81 | { | 81 | { |
82 | struct i2c_gpio_platform_data *pdata; | 82 | struct i2c_gpio_platform_data *pdata; |
83 | struct i2c_algo_bit_data *bit_data; | 83 | struct i2c_algo_bit_data *bit_data; |
@@ -174,7 +174,7 @@ err_alloc_adap: | |||
174 | return ret; | 174 | return ret; |
175 | } | 175 | } |
176 | 176 | ||
177 | static int __exit i2c_gpio_remove(struct platform_device *pdev) | 177 | static int __devexit i2c_gpio_remove(struct platform_device *pdev) |
178 | { | 178 | { |
179 | struct i2c_gpio_platform_data *pdata; | 179 | struct i2c_gpio_platform_data *pdata; |
180 | struct i2c_adapter *adap; | 180 | struct i2c_adapter *adap; |
@@ -196,14 +196,15 @@ static struct platform_driver i2c_gpio_driver = { | |||
196 | .name = "i2c-gpio", | 196 | .name = "i2c-gpio", |
197 | .owner = THIS_MODULE, | 197 | .owner = THIS_MODULE, |
198 | }, | 198 | }, |
199 | .remove = __exit_p(i2c_gpio_remove), | 199 | .probe = i2c_gpio_probe, |
200 | .remove = __devexit_p(i2c_gpio_remove), | ||
200 | }; | 201 | }; |
201 | 202 | ||
202 | static int __init i2c_gpio_init(void) | 203 | static int __init i2c_gpio_init(void) |
203 | { | 204 | { |
204 | int ret; | 205 | int ret; |
205 | 206 | ||
206 | ret = platform_driver_probe(&i2c_gpio_driver, i2c_gpio_probe); | 207 | ret = platform_driver_register(&i2c_gpio_driver); |
207 | if (ret) | 208 | if (ret) |
208 | printk(KERN_ERR "i2c-gpio: probe failed: %d\n", ret); | 209 | printk(KERN_ERR "i2c-gpio: probe failed: %d\n", ret); |
209 | 210 | ||
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c index 5af9e6521e6c..05d72e981353 100644 --- a/drivers/i2c/busses/i2c-ixp2000.c +++ b/drivers/i2c/busses/i2c-ixp2000.c | |||
@@ -33,8 +33,8 @@ | |||
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 | 35 | ||
36 | #include <asm/hardware.h> /* Pick up IXP2000-specific bits */ | 36 | #include <mach/hardware.h> /* Pick up IXP2000-specific bits */ |
37 | #include <asm/arch/gpio.h> | 37 | #include <mach/gpio.h> |
38 | 38 | ||
39 | static inline int ixp2000_scl_pin(void *data) | 39 | static inline int ixp2000_scl_pin(void *data) |
40 | { | 40 | { |
diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c index d1a4cbcf2aa4..29015eb9ca46 100644 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c | |||
@@ -150,6 +150,9 @@ static int __init nforce2_s4985_init(void) | |||
150 | int i, error; | 150 | int i, error; |
151 | union i2c_smbus_data ioconfig; | 151 | union i2c_smbus_data ioconfig; |
152 | 152 | ||
153 | if (!nforce2_smbus) | ||
154 | return -ENODEV; | ||
155 | |||
153 | /* Configure the PCA9556 multiplexer */ | 156 | /* Configure the PCA9556 multiplexer */ |
154 | ioconfig.byte = 0x00; /* All I/O to output mode */ | 157 | ioconfig.byte = 0x00; /* All I/O to output mode */ |
155 | error = i2c_smbus_xfer(nforce2_smbus, 0x18, 0, I2C_SMBUS_WRITE, 0x03, | 158 | error = i2c_smbus_xfer(nforce2_smbus, 0x18, 0, I2C_SMBUS_WRITE, 0x03, |
@@ -161,8 +164,6 @@ static int __init nforce2_s4985_init(void) | |||
161 | } | 164 | } |
162 | 165 | ||
163 | /* Unregister physical bus */ | 166 | /* Unregister physical bus */ |
164 | if (!nforce2_smbus) | ||
165 | return -ENODEV; | ||
166 | error = i2c_del_adapter(nforce2_smbus); | 167 | error = i2c_del_adapter(nforce2_smbus); |
167 | if (error) { | 168 | if (error) { |
168 | dev_err(&nforce2_smbus->dev, "Physical bus removal failed\n"); | 169 | dev_err(&nforce2_smbus->dev, "Physical bus removal failed\n"); |
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c index 1ca21084ffcf..ec15cff556b9 100644 --- a/drivers/i2c/busses/i2c-pnx.c +++ b/drivers/i2c/busses/i2c-pnx.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/completion.h> | 19 | #include <linux/completion.h> |
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/i2c-pnx.h> | 21 | #include <linux/i2c-pnx.h> |
22 | #include <asm/hardware.h> | 22 | #include <mach/hardware.h> |
23 | #include <asm/irq.h> | 23 | #include <asm/irq.h> |
24 | #include <asm/uaccess.h> | 24 | #include <asm/uaccess.h> |
25 | 25 | ||
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index af9e6034d7fb..44d838410f15 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
@@ -34,11 +34,11 @@ | |||
34 | #include <linux/err.h> | 34 | #include <linux/err.h> |
35 | #include <linux/clk.h> | 35 | #include <linux/clk.h> |
36 | 36 | ||
37 | #include <asm/hardware.h> | 37 | #include <mach/hardware.h> |
38 | #include <asm/irq.h> | 38 | #include <asm/irq.h> |
39 | #include <asm/io.h> | 39 | #include <asm/io.h> |
40 | #include <asm/arch/i2c.h> | 40 | #include <mach/i2c.h> |
41 | #include <asm/arch/pxa-regs.h> | 41 | #include <mach/pxa-regs.h> |
42 | 42 | ||
43 | struct pxa_i2c { | 43 | struct pxa_i2c { |
44 | spinlock_t lock; | 44 | spinlock_t lock; |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 007390ad9810..c772e02c2803 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -33,12 +33,13 @@ | |||
33 | #include <linux/err.h> | 33 | #include <linux/err.h> |
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 | 37 | ||
37 | #include <asm/hardware.h> | 38 | #include <mach/hardware.h> |
38 | #include <asm/irq.h> | 39 | #include <asm/irq.h> |
39 | #include <asm/io.h> | 40 | #include <asm/io.h> |
40 | 41 | ||
41 | #include <asm/arch/regs-gpio.h> | 42 | #include <mach/regs-gpio.h> |
42 | #include <asm/plat-s3c/regs-iic.h> | 43 | #include <asm/plat-s3c/regs-iic.h> |
43 | #include <asm/plat-s3c/iic.h> | 44 | #include <asm/plat-s3c/iic.h> |
44 | 45 | ||
@@ -64,6 +65,7 @@ struct s3c24xx_i2c { | |||
64 | unsigned int tx_setup; | 65 | unsigned int tx_setup; |
65 | 66 | ||
66 | enum s3c24xx_i2c_state state; | 67 | enum s3c24xx_i2c_state state; |
68 | unsigned long clkrate; | ||
67 | 69 | ||
68 | void __iomem *regs; | 70 | void __iomem *regs; |
69 | struct clk *clk; | 71 | struct clk *clk; |
@@ -71,6 +73,10 @@ struct s3c24xx_i2c { | |||
71 | struct resource *irq; | 73 | struct resource *irq; |
72 | struct resource *ioarea; | 74 | struct resource *ioarea; |
73 | struct i2c_adapter adap; | 75 | struct i2c_adapter adap; |
76 | |||
77 | #ifdef CONFIG_CPU_FREQ | ||
78 | struct notifier_block freq_transition; | ||
79 | #endif | ||
74 | }; | 80 | }; |
75 | 81 | ||
76 | /* default platform data to use if not supplied in the platform_device | 82 | /* default platform data to use if not supplied in the platform_device |
@@ -501,6 +507,9 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int | |||
501 | unsigned long timeout; | 507 | unsigned long timeout; |
502 | int ret; | 508 | int ret; |
503 | 509 | ||
510 | if (!readl(i2c->regs + S3C2410_IICCON) & S3C2410_IICCON_IRQEN) | ||
511 | return -EIO; | ||
512 | |||
504 | ret = s3c24xx_i2c_set_master(i2c); | 513 | ret = s3c24xx_i2c_set_master(i2c); |
505 | if (ret != 0) { | 514 | if (ret != 0) { |
506 | dev_err(i2c->dev, "cannot get bus (error %d)\n", ret); | 515 | dev_err(i2c->dev, "cannot get bus (error %d)\n", ret); |
@@ -636,27 +645,28 @@ static inline int freq_acceptable(unsigned int freq, unsigned int wanted) | |||
636 | return (diff >= -2 && diff <= 2); | 645 | return (diff >= -2 && diff <= 2); |
637 | } | 646 | } |
638 | 647 | ||
639 | /* s3c24xx_i2c_getdivisor | 648 | /* s3c24xx_i2c_clockrate |
640 | * | 649 | * |
641 | * work out a divisor for the user requested frequency setting, | 650 | * work out a divisor for the user requested frequency setting, |
642 | * either by the requested frequency, or scanning the acceptable | 651 | * either by the requested frequency, or scanning the acceptable |
643 | * range of frequencies until something is found | 652 | * range of frequencies until something is found |
644 | */ | 653 | */ |
645 | 654 | ||
646 | static int s3c24xx_i2c_getdivisor(struct s3c24xx_i2c *i2c, | 655 | static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got) |
647 | struct s3c2410_platform_i2c *pdata, | ||
648 | unsigned long *iicon, | ||
649 | unsigned int *got) | ||
650 | { | 656 | { |
657 | struct s3c2410_platform_i2c *pdata; | ||
651 | unsigned long clkin = clk_get_rate(i2c->clk); | 658 | unsigned long clkin = clk_get_rate(i2c->clk); |
652 | |||
653 | unsigned int divs, div1; | 659 | unsigned int divs, div1; |
660 | u32 iiccon; | ||
654 | int freq; | 661 | int freq; |
655 | int start, end; | 662 | int start, end; |
656 | 663 | ||
664 | i2c->clkrate = clkin; | ||
665 | |||
666 | pdata = s3c24xx_i2c_get_platformdata(i2c->adap.dev.parent); | ||
657 | clkin /= 1000; /* clkin now in KHz */ | 667 | clkin /= 1000; /* clkin now in KHz */ |
658 | 668 | ||
659 | dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n", | 669 | dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n", |
660 | pdata, pdata->bus_freq, pdata->min_freq, pdata->max_freq); | 670 | pdata, pdata->bus_freq, pdata->min_freq, pdata->max_freq); |
661 | 671 | ||
662 | if (pdata->bus_freq != 0) { | 672 | if (pdata->bus_freq != 0) { |
@@ -688,11 +698,79 @@ static int s3c24xx_i2c_getdivisor(struct s3c24xx_i2c *i2c, | |||
688 | 698 | ||
689 | found: | 699 | found: |
690 | *got = freq; | 700 | *got = freq; |
691 | *iicon |= (divs-1); | 701 | |
692 | *iicon |= (div1 == 512) ? S3C2410_IICCON_TXDIV_512 : 0; | 702 | iiccon = readl(i2c->regs + S3C2410_IICCON); |
703 | iiccon &= ~(S3C2410_IICCON_SCALEMASK | S3C2410_IICCON_TXDIV_512); | ||
704 | iiccon |= (divs-1); | ||
705 | |||
706 | if (div1 == 512) | ||
707 | iiccon |= S3C2410_IICCON_TXDIV_512; | ||
708 | |||
709 | writel(iiccon, i2c->regs + S3C2410_IICCON); | ||
710 | |||
711 | return 0; | ||
712 | } | ||
713 | |||
714 | #ifdef CONFIG_CPU_FREQ | ||
715 | |||
716 | #define freq_to_i2c(_n) container_of(_n, struct s3c24xx_i2c, freq_transition) | ||
717 | |||
718 | static int s3c24xx_i2c_cpufreq_transition(struct notifier_block *nb, | ||
719 | unsigned long val, void *data) | ||
720 | { | ||
721 | struct s3c24xx_i2c *i2c = freq_to_i2c(nb); | ||
722 | unsigned long flags; | ||
723 | unsigned int got; | ||
724 | int delta_f; | ||
725 | int ret; | ||
726 | |||
727 | delta_f = clk_get_rate(i2c->clk) - i2c->clkrate; | ||
728 | |||
729 | /* if we're post-change and the input clock has slowed down | ||
730 | * or at pre-change and the clock is about to speed up, then | ||
731 | * adjust our clock rate. <0 is slow, >0 speedup. | ||
732 | */ | ||
733 | |||
734 | if ((val == CPUFREQ_POSTCHANGE && delta_f < 0) || | ||
735 | (val == CPUFREQ_PRECHANGE && delta_f > 0)) { | ||
736 | spin_lock_irqsave(&i2c->lock, flags); | ||
737 | ret = s3c24xx_i2c_clockrate(i2c, &got); | ||
738 | spin_unlock_irqrestore(&i2c->lock, flags); | ||
739 | |||
740 | if (ret < 0) | ||
741 | dev_err(i2c->dev, "cannot find frequency\n"); | ||
742 | else | ||
743 | dev_info(i2c->dev, "setting freq %d\n", got); | ||
744 | } | ||
745 | |||
746 | return 0; | ||
747 | } | ||
748 | |||
749 | static inline int s3c24xx_i2c_register_cpufreq(struct s3c24xx_i2c *i2c) | ||
750 | { | ||
751 | i2c->freq_transition.notifier_call = s3c24xx_i2c_cpufreq_transition; | ||
752 | |||
753 | return cpufreq_register_notifier(&i2c->freq_transition, | ||
754 | CPUFREQ_TRANSITION_NOTIFIER); | ||
755 | } | ||
756 | |||
757 | static inline void s3c24xx_i2c_deregister_cpufreq(struct s3c24xx_i2c *i2c) | ||
758 | { | ||
759 | cpufreq_unregister_notifier(&i2c->freq_transition, | ||
760 | CPUFREQ_TRANSITION_NOTIFIER); | ||
761 | } | ||
762 | |||
763 | #else | ||
764 | static inline int s3c24xx_i2c_register_cpufreq(struct s3c24xx_i2c *i2c) | ||
765 | { | ||
693 | return 0; | 766 | return 0; |
694 | } | 767 | } |
695 | 768 | ||
769 | static inline void s3c24xx_i2c_deregister_cpufreq(struct s3c24xx_i2c *i2c) | ||
770 | { | ||
771 | } | ||
772 | #endif | ||
773 | |||
696 | /* s3c24xx_i2c_init | 774 | /* s3c24xx_i2c_init |
697 | * | 775 | * |
698 | * initialise the controller, set the IO lines and frequency | 776 | * initialise the controller, set the IO lines and frequency |
@@ -719,9 +797,12 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c) | |||
719 | 797 | ||
720 | dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr); | 798 | dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr); |
721 | 799 | ||
800 | writel(iicon, i2c->regs + S3C2410_IICCON); | ||
801 | |||
722 | /* we need to work out the divisors for the clock... */ | 802 | /* we need to work out the divisors for the clock... */ |
723 | 803 | ||
724 | if (s3c24xx_i2c_getdivisor(i2c, pdata, &iicon, &freq) != 0) { | 804 | if (s3c24xx_i2c_clockrate(i2c, &freq) != 0) { |
805 | writel(0, i2c->regs + S3C2410_IICCON); | ||
725 | dev_err(i2c->dev, "cannot meet bus frequency required\n"); | 806 | dev_err(i2c->dev, "cannot meet bus frequency required\n"); |
726 | return -EINVAL; | 807 | return -EINVAL; |
727 | } | 808 | } |
@@ -730,8 +811,6 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c) | |||
730 | 811 | ||
731 | dev_info(i2c->dev, "bus frequency set to %d KHz\n", freq); | 812 | dev_info(i2c->dev, "bus frequency set to %d KHz\n", freq); |
732 | dev_dbg(i2c->dev, "S3C2410_IICCON=0x%02lx\n", iicon); | 813 | dev_dbg(i2c->dev, "S3C2410_IICCON=0x%02lx\n", iicon); |
733 | |||
734 | writel(iicon, i2c->regs + S3C2410_IICCON); | ||
735 | 814 | ||
736 | /* check for s3c2440 i2c controller */ | 815 | /* check for s3c2440 i2c controller */ |
737 | 816 | ||
@@ -752,9 +831,12 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c) | |||
752 | static int s3c24xx_i2c_probe(struct platform_device *pdev) | 831 | static int s3c24xx_i2c_probe(struct platform_device *pdev) |
753 | { | 832 | { |
754 | struct s3c24xx_i2c *i2c = &s3c24xx_i2c; | 833 | struct s3c24xx_i2c *i2c = &s3c24xx_i2c; |
834 | struct s3c2410_platform_i2c *pdata; | ||
755 | struct resource *res; | 835 | struct resource *res; |
756 | int ret; | 836 | int ret; |
757 | 837 | ||
838 | pdata = s3c24xx_i2c_get_platformdata(&pdev->dev); | ||
839 | |||
758 | /* find the clock and enable it */ | 840 | /* find the clock and enable it */ |
759 | 841 | ||
760 | i2c->dev = &pdev->dev; | 842 | i2c->dev = &pdev->dev; |
@@ -832,17 +914,34 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
832 | dev_dbg(&pdev->dev, "irq resource %p (%lu)\n", res, | 914 | dev_dbg(&pdev->dev, "irq resource %p (%lu)\n", res, |
833 | (unsigned long)res->start); | 915 | (unsigned long)res->start); |
834 | 916 | ||
835 | ret = i2c_add_adapter(&i2c->adap); | 917 | ret = s3c24xx_i2c_register_cpufreq(i2c); |
836 | if (ret < 0) { | 918 | if (ret < 0) { |
837 | dev_err(&pdev->dev, "failed to add bus to i2c core\n"); | 919 | dev_err(&pdev->dev, "failed to register cpufreq notifier\n"); |
838 | goto err_irq; | 920 | goto err_irq; |
839 | } | 921 | } |
840 | 922 | ||
923 | /* Note, previous versions of the driver used i2c_add_adapter() | ||
924 | * to add the bus at any number. We now pass the bus number via | ||
925 | * the platform data, so if unset it will now default to always | ||
926 | * being bus 0. | ||
927 | */ | ||
928 | |||
929 | i2c->adap.nr = pdata->bus_num; | ||
930 | |||
931 | ret = i2c_add_numbered_adapter(&i2c->adap); | ||
932 | if (ret < 0) { | ||
933 | dev_err(&pdev->dev, "failed to add bus to i2c core\n"); | ||
934 | goto err_cpufreq; | ||
935 | } | ||
936 | |||
841 | platform_set_drvdata(pdev, i2c); | 937 | platform_set_drvdata(pdev, i2c); |
842 | 938 | ||
843 | dev_info(&pdev->dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id); | 939 | dev_info(&pdev->dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id); |
844 | return 0; | 940 | return 0; |
845 | 941 | ||
942 | err_cpufreq: | ||
943 | s3c24xx_i2c_deregister_cpufreq(i2c); | ||
944 | |||
846 | err_irq: | 945 | err_irq: |
847 | free_irq(i2c->irq->start, i2c); | 946 | free_irq(i2c->irq->start, i2c); |
848 | 947 | ||
@@ -870,6 +969,8 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev) | |||
870 | { | 969 | { |
871 | struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); | 970 | struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); |
872 | 971 | ||
972 | s3c24xx_i2c_deregister_cpufreq(i2c); | ||
973 | |||
873 | i2c_del_adapter(&i2c->adap); | 974 | i2c_del_adapter(&i2c->adap); |
874 | free_irq(i2c->irq->start, i2c); | 975 | free_irq(i2c->irq->start, i2c); |
875 | 976 | ||
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig index 50e0a4653741..a95cb9465d65 100644 --- a/drivers/i2c/chips/Kconfig +++ b/drivers/i2c/chips/Kconfig | |||
@@ -126,7 +126,7 @@ config ISP1301_OMAP | |||
126 | 126 | ||
127 | config TPS65010 | 127 | config TPS65010 |
128 | tristate "TPS6501x Power Management chips" | 128 | tristate "TPS6501x Power Management chips" |
129 | depends on HAVE_GPIO_LIB | 129 | depends on GPIOLIB |
130 | default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK | 130 | default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK |
131 | help | 131 | help |
132 | If you say yes here you get support for the TPS6501x series of | 132 | If you say yes here you get support for the TPS6501x series of |
diff --git a/drivers/i2c/chips/at24.c b/drivers/i2c/chips/at24.c index e764c94f3e3d..2a4acb269569 100644 --- a/drivers/i2c/chips/at24.c +++ b/drivers/i2c/chips/at24.c | |||
@@ -188,7 +188,7 @@ static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf, | |||
188 | count = I2C_SMBUS_BLOCK_MAX; | 188 | count = I2C_SMBUS_BLOCK_MAX; |
189 | status = i2c_smbus_read_i2c_block_data(client, offset, | 189 | status = i2c_smbus_read_i2c_block_data(client, offset, |
190 | count, buf); | 190 | count, buf); |
191 | dev_dbg(&client->dev, "smbus read %zd@%d --> %d\n", | 191 | dev_dbg(&client->dev, "smbus read %zu@%d --> %d\n", |
192 | count, offset, status); | 192 | count, offset, status); |
193 | return (status < 0) ? -EIO : status; | 193 | return (status < 0) ? -EIO : status; |
194 | } | 194 | } |
@@ -214,7 +214,7 @@ static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf, | |||
214 | msg[1].len = count; | 214 | msg[1].len = count; |
215 | 215 | ||
216 | status = i2c_transfer(client->adapter, msg, 2); | 216 | status = i2c_transfer(client->adapter, msg, 2); |
217 | dev_dbg(&client->dev, "i2c read %zd@%d --> %d\n", | 217 | dev_dbg(&client->dev, "i2c read %zu@%d --> %d\n", |
218 | count, offset, status); | 218 | count, offset, status); |
219 | 219 | ||
220 | if (status == 2) | 220 | if (status == 2) |
@@ -334,7 +334,7 @@ static ssize_t at24_eeprom_write(struct at24_data *at24, char *buf, | |||
334 | if (status == 1) | 334 | if (status == 1) |
335 | status = count; | 335 | status = count; |
336 | } | 336 | } |
337 | dev_dbg(&client->dev, "write %zd@%d --> %zd (%ld)\n", | 337 | dev_dbg(&client->dev, "write %zu@%d --> %zd (%ld)\n", |
338 | count, offset, status, jiffies); | 338 | count, offset, status, jiffies); |
339 | 339 | ||
340 | if (status == count) | 340 | if (status == count) |
@@ -512,7 +512,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
512 | 512 | ||
513 | i2c_set_clientdata(client, at24); | 513 | i2c_set_clientdata(client, at24); |
514 | 514 | ||
515 | dev_info(&client->dev, "%Zd byte %s EEPROM %s\n", | 515 | dev_info(&client->dev, "%zu byte %s EEPROM %s\n", |
516 | at24->bin.size, client->name, | 516 | at24->bin.size, client->name, |
517 | writable ? "(writable)" : "(read-only)"); | 517 | writable ? "(writable)" : "(read-only)"); |
518 | dev_dbg(&client->dev, | 518 | dev_dbg(&client->dev, |
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index 03a33f1b9cd3..4655b794ebe3 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/workqueue.h> | 33 | #include <linux/workqueue.h> |
34 | 34 | ||
35 | #include <asm/irq.h> | 35 | #include <asm/irq.h> |
36 | #include <asm/arch/usb.h> | 36 | #include <mach/usb.h> |
37 | 37 | ||
38 | 38 | ||
39 | #ifndef DEBUG | 39 | #ifndef DEBUG |
@@ -94,7 +94,7 @@ struct isp1301 { | |||
94 | /* board-specific PM hooks */ | 94 | /* board-specific PM hooks */ |
95 | 95 | ||
96 | #include <asm/gpio.h> | 96 | #include <asm/gpio.h> |
97 | #include <asm/arch/mux.h> | 97 | #include <mach/mux.h> |
98 | #include <asm/mach-types.h> | 98 | #include <asm/mach-types.h> |
99 | 99 | ||
100 | 100 | ||
@@ -1593,7 +1593,7 @@ fail1: | |||
1593 | if (machine_is_omap_h2()) { | 1593 | if (machine_is_omap_h2()) { |
1594 | /* full speed signaling by default */ | 1594 | /* full speed signaling by default */ |
1595 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, | 1595 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, |
1596 | MC1_SPEED_REG); | 1596 | MC1_SPEED); |
1597 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_2, | 1597 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_2, |
1598 | MC2_SPD_SUSP_CTRL); | 1598 | MC2_SPD_SUSP_CTRL); |
1599 | 1599 | ||
diff --git a/drivers/i2c/chips/menelaus.c b/drivers/i2c/chips/menelaus.c index b36db1797c11..176126d3a01d 100644 --- a/drivers/i2c/chips/menelaus.c +++ b/drivers/i2c/chips/menelaus.c | |||
@@ -41,11 +41,10 @@ | |||
41 | #include <linux/rtc.h> | 41 | #include <linux/rtc.h> |
42 | #include <linux/bcd.h> | 42 | #include <linux/bcd.h> |
43 | 43 | ||
44 | #include <asm/mach-types.h> | ||
45 | #include <asm/mach/irq.h> | 44 | #include <asm/mach/irq.h> |
46 | 45 | ||
47 | #include <asm/arch/gpio.h> | 46 | #include <mach/gpio.h> |
48 | #include <asm/arch/menelaus.h> | 47 | #include <mach/menelaus.h> |
49 | 48 | ||
50 | #define DRIVER_NAME "menelaus" | 49 | #define DRIVER_NAME "menelaus" |
51 | 50 | ||
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index 85949685191b..cf02e8fceb42 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -636,6 +636,8 @@ static int tps65010_probe(struct i2c_client *client, | |||
636 | tps->outmask = board->outmask; | 636 | tps->outmask = board->outmask; |
637 | 637 | ||
638 | tps->chip.label = client->name; | 638 | tps->chip.label = client->name; |
639 | tps->chip.dev = &client->dev; | ||
640 | tps->chip.owner = THIS_MODULE; | ||
639 | 641 | ||
640 | tps->chip.set = tps65010_gpio_set; | 642 | tps->chip.set = tps65010_gpio_set; |
641 | tps->chip.direction_output = tps65010_output; | 643 | tps->chip.direction_output = tps65010_output; |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 7bf38c418086..550853f79ae8 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -813,7 +813,12 @@ static int i2c_check_addr(struct i2c_adapter *adapter, int addr) | |||
813 | int i2c_attach_client(struct i2c_client *client) | 813 | int i2c_attach_client(struct i2c_client *client) |
814 | { | 814 | { |
815 | struct i2c_adapter *adapter = client->adapter; | 815 | struct i2c_adapter *adapter = client->adapter; |
816 | int res = 0; | 816 | int res; |
817 | |||
818 | /* Check for address business */ | ||
819 | res = i2c_check_addr(adapter, client->addr); | ||
820 | if (res) | ||
821 | return res; | ||
817 | 822 | ||
818 | client->dev.parent = &client->adapter->dev; | 823 | client->dev.parent = &client->adapter->dev; |
819 | client->dev.bus = &i2c_bus_type; | 824 | client->dev.bus = &i2c_bus_type; |
@@ -1451,9 +1456,11 @@ i2c_new_probed_device(struct i2c_adapter *adap, | |||
1451 | if ((addr_list[i] & ~0x07) == 0x30 | 1456 | if ((addr_list[i] & ~0x07) == 0x30 |
1452 | || (addr_list[i] & ~0x0f) == 0x50 | 1457 | || (addr_list[i] & ~0x0f) == 0x50 |
1453 | || !i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK)) { | 1458 | || !i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK)) { |
1459 | union i2c_smbus_data data; | ||
1460 | |||
1454 | if (i2c_smbus_xfer(adap, addr_list[i], 0, | 1461 | if (i2c_smbus_xfer(adap, addr_list[i], 0, |
1455 | I2C_SMBUS_READ, 0, | 1462 | I2C_SMBUS_READ, 0, |
1456 | I2C_SMBUS_BYTE, NULL) >= 0) | 1463 | I2C_SMBUS_BYTE, &data) >= 0) |
1457 | break; | 1464 | break; |
1458 | } else { | 1465 | } else { |
1459 | if (i2c_smbus_xfer(adap, addr_list[i], 0, | 1466 | if (i2c_smbus_xfer(adap, addr_list[i], 0, |
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 9d55c6383b23..af4491fa7e34 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -147,7 +147,7 @@ static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count, | |||
147 | if (tmp==NULL) | 147 | if (tmp==NULL) |
148 | return -ENOMEM; | 148 | return -ENOMEM; |
149 | 149 | ||
150 | pr_debug("i2c-dev: i2c-%d reading %zd bytes.\n", | 150 | pr_debug("i2c-dev: i2c-%d reading %zu bytes.\n", |
151 | iminor(file->f_path.dentry->d_inode), count); | 151 | iminor(file->f_path.dentry->d_inode), count); |
152 | 152 | ||
153 | ret = i2c_master_recv(client,tmp,count); | 153 | ret = i2c_master_recv(client,tmp,count); |
@@ -175,7 +175,7 @@ static ssize_t i2cdev_write (struct file *file, const char __user *buf, size_t c | |||
175 | return -EFAULT; | 175 | return -EFAULT; |
176 | } | 176 | } |
177 | 177 | ||
178 | pr_debug("i2c-dev: i2c-%d writing %zd bytes.\n", | 178 | pr_debug("i2c-dev: i2c-%d writing %zu bytes.\n", |
179 | iminor(file->f_path.dentry->d_inode), count); | 179 | iminor(file->f_path.dentry->d_inode), count); |
180 | 180 | ||
181 | ret = i2c_master_send(client,tmp,count); | 181 | ret = i2c_master_send(client,tmp,count); |