diff options
Diffstat (limited to 'drivers/i2c/busses')
26 files changed, 1055 insertions, 188 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 6ee997b2817c..7f95905bbb9d 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -55,7 +55,7 @@ config I2C_AMD756 | |||
55 | 55 | ||
56 | config I2C_AMD756_S4882 | 56 | config I2C_AMD756_S4882 |
57 | tristate "SMBus multiplexing on the Tyan S4882" | 57 | tristate "SMBus multiplexing on the Tyan S4882" |
58 | depends on I2C_AMD756 && EXPERIMENTAL | 58 | depends on I2C_AMD756 && X86 && EXPERIMENTAL |
59 | help | 59 | help |
60 | Enabling this option will add specific SMBus support for the Tyan | 60 | Enabling this option will add specific SMBus support for the Tyan |
61 | S4882 motherboard. On this 4-CPU board, the SMBus is multiplexed | 61 | S4882 motherboard. On this 4-CPU board, the SMBus is multiplexed |
@@ -97,6 +97,7 @@ config I2C_I801 | |||
97 | ICH9 | 97 | ICH9 |
98 | Tolapai | 98 | Tolapai |
99 | ICH10 | 99 | ICH10 |
100 | PCH | ||
100 | 101 | ||
101 | This driver can also be built as a module. If so, the module | 102 | This driver can also be built as a module. If so, the module |
102 | will be called i2c-i801. | 103 | will be called i2c-i801. |
@@ -148,7 +149,7 @@ config I2C_NFORCE2 | |||
148 | 149 | ||
149 | config I2C_NFORCE2_S4985 | 150 | config I2C_NFORCE2_S4985 |
150 | tristate "SMBus multiplexing on the Tyan S4985" | 151 | tristate "SMBus multiplexing on the Tyan S4985" |
151 | depends on I2C_NFORCE2 && EXPERIMENTAL | 152 | depends on I2C_NFORCE2 && X86 && EXPERIMENTAL |
152 | help | 153 | help |
153 | Enabling this option will add specific SMBus support for the Tyan | 154 | Enabling this option will add specific SMBus support for the Tyan |
154 | S4985 motherboard. On this 4-CPU board, the SMBus is multiplexed | 155 | S4985 motherboard. On this 4-CPU board, the SMBus is multiplexed |
@@ -209,7 +210,7 @@ config I2C_VIA | |||
209 | will be called i2c-via. | 210 | will be called i2c-via. |
210 | 211 | ||
211 | config I2C_VIAPRO | 212 | config I2C_VIAPRO |
212 | tristate "VIA VT82C596/82C686/82xx and CX700" | 213 | tristate "VIA VT82C596/82C686/82xx and CX700/VX800/VX820" |
213 | depends on PCI | 214 | depends on PCI |
214 | help | 215 | help |
215 | If you say yes to this option, support will be included for the VIA | 216 | If you say yes to this option, support will be included for the VIA |
@@ -223,6 +224,8 @@ config I2C_VIAPRO | |||
223 | VT8237R/A/S | 224 | VT8237R/A/S |
224 | VT8251 | 225 | VT8251 |
225 | CX700 | 226 | CX700 |
227 | VX800 | ||
228 | VX820 | ||
226 | 229 | ||
227 | This driver can also be built as a module. If so, the module | 230 | This driver can also be built as a module. If so, the module |
228 | will be called i2c-viapro. | 231 | will be called i2c-viapro. |
@@ -330,6 +333,18 @@ config I2C_GPIO | |||
330 | This is a very simple bitbanging I2C driver utilizing the | 333 | This is a very simple bitbanging I2C driver utilizing the |
331 | arch-neutral GPIO API to control the SCL and SDA lines. | 334 | arch-neutral GPIO API to control the SCL and SDA lines. |
332 | 335 | ||
336 | config I2C_HIGHLANDER | ||
337 | tristate "Highlander FPGA SMBus interface" | ||
338 | depends on SH_HIGHLANDER | ||
339 | help | ||
340 | If you say yes to this option, support will be included for | ||
341 | the SMBus interface located in the FPGA on various Highlander | ||
342 | boards, particularly the R0P7780LC0011RL and R0P7785LC0011RL | ||
343 | FPGAs. This is wholly unrelated to the SoC I2C. | ||
344 | |||
345 | This driver can also be built as a module. If so, the module | ||
346 | will be called i2c-highlander. | ||
347 | |||
333 | config I2C_IBM_IIC | 348 | config I2C_IBM_IIC |
334 | tristate "IBM PPC 4xx on-chip I2C interface" | 349 | tristate "IBM PPC 4xx on-chip I2C interface" |
335 | depends on 4xx | 350 | depends on 4xx |
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index 97dbfa2107fe..0c2c4b26cdf1 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile | |||
@@ -31,6 +31,7 @@ obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o | |||
31 | obj-$(CONFIG_I2C_CPM) += i2c-cpm.o | 31 | obj-$(CONFIG_I2C_CPM) += i2c-cpm.o |
32 | obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o | 32 | obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o |
33 | obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o | 33 | obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o |
34 | obj-$(CONFIG_I2C_HIGHLANDER) += i2c-highlander.o | ||
34 | obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o | 35 | obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o |
35 | obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o | 36 | obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o |
36 | obj-$(CONFIG_I2C_IXP2000) += i2c-ixp2000.o | 37 | obj-$(CONFIG_I2C_IXP2000) += i2c-ixp2000.o |
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-amd756.c b/drivers/i2c/busses/i2c-amd756.c index 1ea39254dac6..424dad6f18d8 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c | |||
@@ -332,10 +332,6 @@ static int __devinit amd756_probe(struct pci_dev *pdev, | |||
332 | int error; | 332 | int error; |
333 | u8 temp; | 333 | u8 temp; |
334 | 334 | ||
335 | /* driver_data might come from user-space, so check it */ | ||
336 | if (id->driver_data >= ARRAY_SIZE(chipname)) | ||
337 | return -EINVAL; | ||
338 | |||
339 | if (amd756_ioport) { | 335 | if (amd756_ioport) { |
340 | dev_err(&pdev->dev, "Only one device supported " | 336 | dev_err(&pdev->dev, "Only one device supported " |
341 | "(you have a strange motherboard, btw)\n"); | 337 | "(you have a strange motherboard, btw)\n"); |
@@ -412,7 +408,6 @@ static struct pci_driver amd756_driver = { | |||
412 | .id_table = amd756_ids, | 408 | .id_table = amd756_ids, |
413 | .probe = amd756_probe, | 409 | .probe = amd756_probe, |
414 | .remove = __devexit_p(amd756_remove), | 410 | .remove = __devexit_p(amd756_remove), |
415 | .dynids.use_driver_data = 1, | ||
416 | }; | 411 | }; |
417 | 412 | ||
418 | static int __init amd756_init(void) | 413 | static int __init amd756_init(void) |
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index 73d61946a534..9efb02137254 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c | |||
@@ -14,7 +14,6 @@ | |||
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/version.h> | ||
18 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
19 | #include <linux/err.h> | 18 | #include <linux/err.h> |
20 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
@@ -27,9 +26,9 @@ | |||
27 | 26 | ||
28 | #include <asm/io.h> | 27 | #include <asm/io.h> |
29 | 28 | ||
30 | #include <asm/arch/at91_twi.h> | 29 | #include <mach/at91_twi.h> |
31 | #include <asm/arch/board.h> | 30 | #include <mach/board.h> |
32 | #include <asm/arch/cpu.h> | 31 | #include <mach/cpu.h> |
33 | 32 | ||
34 | #define TWI_CLOCK 100000 /* Hz. max 400 Kbits/sec */ | 33 | #define TWI_CLOCK 100000 /* Hz. max 400 Kbits/sec */ |
35 | 34 | ||
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-cpm.c b/drivers/i2c/busses/i2c-cpm.c index 8164de1f4d72..228f75723063 100644 --- a/drivers/i2c/busses/i2c-cpm.c +++ b/drivers/i2c/busses/i2c-cpm.c | |||
@@ -423,7 +423,6 @@ static const struct i2c_adapter cpm_ops = { | |||
423 | .owner = THIS_MODULE, | 423 | .owner = THIS_MODULE, |
424 | .name = "i2c-cpm", | 424 | .name = "i2c-cpm", |
425 | .algo = &cpm_i2c_algo, | 425 | .algo = &cpm_i2c_algo, |
426 | .class = I2C_CLASS_HWMON | I2C_CLASS_SPD, | ||
427 | }; | 426 | }; |
428 | 427 | ||
429 | static int __devinit cpm_i2c_setup(struct cpm_i2c *cpm) | 428 | static int __devinit cpm_i2c_setup(struct cpm_i2c *cpm) |
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-elektor.c b/drivers/i2c/busses/i2c-elektor.c index 7f38c01fb3a0..0ed3ccb81b63 100644 --- a/drivers/i2c/busses/i2c-elektor.c +++ b/drivers/i2c/busses/i2c-elektor.c | |||
@@ -104,7 +104,8 @@ static int pcf_isa_getclock(void *data) | |||
104 | return (clock); | 104 | return (clock); |
105 | } | 105 | } |
106 | 106 | ||
107 | static void pcf_isa_waitforpin(void) { | 107 | static void pcf_isa_waitforpin(void *data) |
108 | { | ||
108 | DEFINE_WAIT(wait); | 109 | DEFINE_WAIT(wait); |
109 | int timeout = 2; | 110 | int timeout = 2; |
110 | unsigned long flags; | 111 | unsigned long flags; |
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-highlander.c b/drivers/i2c/busses/i2c-highlander.c new file mode 100644 index 000000000000..f4d22ae9d294 --- /dev/null +++ b/drivers/i2c/busses/i2c-highlander.c | |||
@@ -0,0 +1,498 @@ | |||
1 | /* | ||
2 | * Renesas Solutions Highlander FPGA I2C/SMBus support. | ||
3 | * | ||
4 | * Supported devices: R0P7780LC0011RL, R0P7785LC0011RL | ||
5 | * | ||
6 | * Copyright (C) 2008 Paul Mundt | ||
7 | * Copyright (C) 2008 Renesas Solutions Corp. | ||
8 | * Copyright (C) 2008 Atom Create Engineering Co., Ltd. | ||
9 | * | ||
10 | * This file is subject to the terms and conditions of the GNU General | ||
11 | * Public License version 2. See the file "COPYING" in the main directory | ||
12 | * of this archive for more details. | ||
13 | */ | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/interrupt.h> | ||
17 | #include <linux/i2c.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <linux/completion.h> | ||
20 | #include <linux/io.h> | ||
21 | #include <linux/delay.h> | ||
22 | |||
23 | #define SMCR 0x00 | ||
24 | #define SMCR_START (1 << 0) | ||
25 | #define SMCR_IRIC (1 << 1) | ||
26 | #define SMCR_BBSY (1 << 2) | ||
27 | #define SMCR_ACKE (1 << 3) | ||
28 | #define SMCR_RST (1 << 4) | ||
29 | #define SMCR_IEIC (1 << 6) | ||
30 | |||
31 | #define SMSMADR 0x02 | ||
32 | |||
33 | #define SMMR 0x04 | ||
34 | #define SMMR_MODE0 (1 << 0) | ||
35 | #define SMMR_MODE1 (1 << 1) | ||
36 | #define SMMR_CAP (1 << 3) | ||
37 | #define SMMR_TMMD (1 << 4) | ||
38 | #define SMMR_SP (1 << 7) | ||
39 | |||
40 | #define SMSADR 0x06 | ||
41 | #define SMTRDR 0x46 | ||
42 | |||
43 | struct highlander_i2c_dev { | ||
44 | struct device *dev; | ||
45 | void __iomem *base; | ||
46 | struct i2c_adapter adapter; | ||
47 | struct completion cmd_complete; | ||
48 | unsigned long last_read_time; | ||
49 | int irq; | ||
50 | u8 *buf; | ||
51 | size_t buf_len; | ||
52 | }; | ||
53 | |||
54 | static int iic_force_poll, iic_force_normal; | ||
55 | static int iic_timeout = 1000, iic_read_delay; | ||
56 | |||
57 | static inline void highlander_i2c_irq_enable(struct highlander_i2c_dev *dev) | ||
58 | { | ||
59 | iowrite16(ioread16(dev->base + SMCR) | SMCR_IEIC, dev->base + SMCR); | ||
60 | } | ||
61 | |||
62 | static inline void highlander_i2c_irq_disable(struct highlander_i2c_dev *dev) | ||
63 | { | ||
64 | iowrite16(ioread16(dev->base + SMCR) & ~SMCR_IEIC, dev->base + SMCR); | ||
65 | } | ||
66 | |||
67 | static inline void highlander_i2c_start(struct highlander_i2c_dev *dev) | ||
68 | { | ||
69 | iowrite16(ioread16(dev->base + SMCR) | SMCR_START, dev->base + SMCR); | ||
70 | } | ||
71 | |||
72 | static inline void highlander_i2c_done(struct highlander_i2c_dev *dev) | ||
73 | { | ||
74 | iowrite16(ioread16(dev->base + SMCR) | SMCR_IRIC, dev->base + SMCR); | ||
75 | } | ||
76 | |||
77 | static void highlander_i2c_setup(struct highlander_i2c_dev *dev) | ||
78 | { | ||
79 | u16 smmr; | ||
80 | |||
81 | smmr = ioread16(dev->base + SMMR); | ||
82 | smmr |= SMMR_TMMD; | ||
83 | |||
84 | if (iic_force_normal) | ||
85 | smmr &= ~SMMR_SP; | ||
86 | else | ||
87 | smmr |= SMMR_SP; | ||
88 | |||
89 | iowrite16(smmr, dev->base + SMMR); | ||
90 | } | ||
91 | |||
92 | static void smbus_write_data(u8 *src, u16 *dst, int len) | ||
93 | { | ||
94 | for (; len > 1; len -= 2) { | ||
95 | *dst++ = be16_to_cpup((u16 *)src); | ||
96 | src += 2; | ||
97 | } | ||
98 | |||
99 | if (len) | ||
100 | *dst = *src << 8; | ||
101 | } | ||
102 | |||
103 | static void smbus_read_data(u16 *src, u8 *dst, int len) | ||
104 | { | ||
105 | for (; len > 1; len -= 2) { | ||
106 | *(u16 *)dst = cpu_to_be16p(src++); | ||
107 | dst += 2; | ||
108 | } | ||
109 | |||
110 | if (len) | ||
111 | *dst = *src >> 8; | ||
112 | } | ||
113 | |||
114 | static void highlander_i2c_command(struct highlander_i2c_dev *dev, | ||
115 | u8 command, int len) | ||
116 | { | ||
117 | unsigned int i; | ||
118 | u16 cmd = (command << 8) | command; | ||
119 | |||
120 | for (i = 0; i < len; i += 2) { | ||
121 | if (len - i == 1) | ||
122 | cmd = command << 8; | ||
123 | iowrite16(cmd, dev->base + SMSADR + i); | ||
124 | dev_dbg(dev->dev, "command data[%x] 0x%04x\n", i/2, cmd); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | static int highlander_i2c_wait_for_bbsy(struct highlander_i2c_dev *dev) | ||
129 | { | ||
130 | unsigned long timeout; | ||
131 | |||
132 | timeout = jiffies + msecs_to_jiffies(iic_timeout); | ||
133 | while (ioread16(dev->base + SMCR) & SMCR_BBSY) { | ||
134 | if (time_after(jiffies, timeout)) { | ||
135 | dev_warn(dev->dev, "timeout waiting for bus ready\n"); | ||
136 | return -ETIMEDOUT; | ||
137 | } | ||
138 | |||
139 | msleep(1); | ||
140 | } | ||
141 | |||
142 | return 0; | ||
143 | } | ||
144 | |||
145 | static int highlander_i2c_reset(struct highlander_i2c_dev *dev) | ||
146 | { | ||
147 | iowrite16(ioread16(dev->base + SMCR) | SMCR_RST, dev->base + SMCR); | ||
148 | return highlander_i2c_wait_for_bbsy(dev); | ||
149 | } | ||
150 | |||
151 | static int highlander_i2c_wait_for_ack(struct highlander_i2c_dev *dev) | ||
152 | { | ||
153 | u16 tmp = ioread16(dev->base + SMCR); | ||
154 | |||
155 | if ((tmp & (SMCR_IRIC | SMCR_ACKE)) == SMCR_ACKE) { | ||
156 | dev_warn(dev->dev, "ack abnormality\n"); | ||
157 | return highlander_i2c_reset(dev); | ||
158 | } | ||
159 | |||
160 | return 0; | ||
161 | } | ||
162 | |||
163 | static irqreturn_t highlander_i2c_irq(int irq, void *dev_id) | ||
164 | { | ||
165 | struct highlander_i2c_dev *dev = dev_id; | ||
166 | |||
167 | highlander_i2c_done(dev); | ||
168 | complete(&dev->cmd_complete); | ||
169 | |||
170 | return IRQ_HANDLED; | ||
171 | } | ||
172 | |||
173 | static void highlander_i2c_poll(struct highlander_i2c_dev *dev) | ||
174 | { | ||
175 | unsigned long timeout; | ||
176 | u16 smcr; | ||
177 | |||
178 | timeout = jiffies + msecs_to_jiffies(iic_timeout); | ||
179 | for (;;) { | ||
180 | smcr = ioread16(dev->base + SMCR); | ||
181 | |||
182 | /* | ||
183 | * Don't bother checking ACKE here, this and the reset | ||
184 | * are handled in highlander_i2c_wait_xfer_done() when | ||
185 | * waiting for the ACK. | ||
186 | */ | ||
187 | |||
188 | if (smcr & SMCR_IRIC) | ||
189 | return; | ||
190 | if (time_after(jiffies, timeout)) | ||
191 | break; | ||
192 | |||
193 | cpu_relax(); | ||
194 | cond_resched(); | ||
195 | } | ||
196 | |||
197 | dev_err(dev->dev, "polling timed out\n"); | ||
198 | } | ||
199 | |||
200 | static inline int highlander_i2c_wait_xfer_done(struct highlander_i2c_dev *dev) | ||
201 | { | ||
202 | if (dev->irq) | ||
203 | wait_for_completion_timeout(&dev->cmd_complete, | ||
204 | msecs_to_jiffies(iic_timeout)); | ||
205 | else | ||
206 | /* busy looping, the IRQ of champions */ | ||
207 | highlander_i2c_poll(dev); | ||
208 | |||
209 | return highlander_i2c_wait_for_ack(dev); | ||
210 | } | ||
211 | |||
212 | static int highlander_i2c_read(struct highlander_i2c_dev *dev) | ||
213 | { | ||
214 | int i, cnt; | ||
215 | u16 data[16]; | ||
216 | |||
217 | if (highlander_i2c_wait_for_bbsy(dev)) | ||
218 | return -EAGAIN; | ||
219 | |||
220 | highlander_i2c_start(dev); | ||
221 | |||
222 | if (highlander_i2c_wait_xfer_done(dev)) { | ||
223 | dev_err(dev->dev, "Arbitration loss\n"); | ||
224 | return -EAGAIN; | ||
225 | } | ||
226 | |||
227 | /* | ||
228 | * The R0P7780LC0011RL FPGA needs a significant delay between | ||
229 | * data read cycles, otherwise the transciever gets confused and | ||
230 | * garbage is returned when the read is subsequently aborted. | ||
231 | * | ||
232 | * It is not sufficient to wait for BBSY. | ||
233 | * | ||
234 | * While this generally only applies to the older SH7780-based | ||
235 | * Highlanders, the same issue can be observed on SH7785 ones, | ||
236 | * albeit less frequently. SH7780-based Highlanders may need | ||
237 | * this to be as high as 1000 ms. | ||
238 | */ | ||
239 | if (iic_read_delay && time_before(jiffies, dev->last_read_time + | ||
240 | msecs_to_jiffies(iic_read_delay))) | ||
241 | msleep(jiffies_to_msecs((dev->last_read_time + | ||
242 | msecs_to_jiffies(iic_read_delay)) - jiffies)); | ||
243 | |||
244 | cnt = (dev->buf_len + 1) >> 1; | ||
245 | for (i = 0; i < cnt; i++) { | ||
246 | data[i] = ioread16(dev->base + SMTRDR + (i * sizeof(u16))); | ||
247 | dev_dbg(dev->dev, "read data[%x] 0x%04x\n", i, data[i]); | ||
248 | } | ||
249 | |||
250 | smbus_read_data(data, dev->buf, dev->buf_len); | ||
251 | |||
252 | dev->last_read_time = jiffies; | ||
253 | |||
254 | return 0; | ||
255 | } | ||
256 | |||
257 | static int highlander_i2c_write(struct highlander_i2c_dev *dev) | ||
258 | { | ||
259 | int i, cnt; | ||
260 | u16 data[16]; | ||
261 | |||
262 | smbus_write_data(dev->buf, data, dev->buf_len); | ||
263 | |||
264 | cnt = (dev->buf_len + 1) >> 1; | ||
265 | for (i = 0; i < cnt; i++) { | ||
266 | iowrite16(data[i], dev->base + SMTRDR + (i * sizeof(u16))); | ||
267 | dev_dbg(dev->dev, "write data[%x] 0x%04x\n", i, data[i]); | ||
268 | } | ||
269 | |||
270 | if (highlander_i2c_wait_for_bbsy(dev)) | ||
271 | return -EAGAIN; | ||
272 | |||
273 | highlander_i2c_start(dev); | ||
274 | |||
275 | return highlander_i2c_wait_xfer_done(dev); | ||
276 | } | ||
277 | |||
278 | static int highlander_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, | ||
279 | unsigned short flags, char read_write, | ||
280 | u8 command, int size, | ||
281 | union i2c_smbus_data *data) | ||
282 | { | ||
283 | struct highlander_i2c_dev *dev = i2c_get_adapdata(adap); | ||
284 | int read = read_write & I2C_SMBUS_READ; | ||
285 | u16 tmp; | ||
286 | |||
287 | init_completion(&dev->cmd_complete); | ||
288 | |||
289 | dev_dbg(dev->dev, "addr %04x, command %02x, read_write %d, size %d\n", | ||
290 | addr, command, read_write, size); | ||
291 | |||
292 | /* | ||
293 | * Set up the buffer and transfer size | ||
294 | */ | ||
295 | switch (size) { | ||
296 | case I2C_SMBUS_BYTE_DATA: | ||
297 | dev->buf = &data->byte; | ||
298 | dev->buf_len = 1; | ||
299 | break; | ||
300 | case I2C_SMBUS_I2C_BLOCK_DATA: | ||
301 | dev->buf = &data->block[1]; | ||
302 | dev->buf_len = data->block[0]; | ||
303 | break; | ||
304 | default: | ||
305 | dev_err(dev->dev, "unsupported command %d\n", size); | ||
306 | return -EINVAL; | ||
307 | } | ||
308 | |||
309 | /* | ||
310 | * Encode the mode setting | ||
311 | */ | ||
312 | tmp = ioread16(dev->base + SMMR); | ||
313 | tmp &= ~(SMMR_MODE0 | SMMR_MODE1); | ||
314 | |||
315 | switch (dev->buf_len) { | ||
316 | case 1: | ||
317 | /* default */ | ||
318 | break; | ||
319 | case 8: | ||
320 | tmp |= SMMR_MODE0; | ||
321 | break; | ||
322 | case 16: | ||
323 | tmp |= SMMR_MODE1; | ||
324 | break; | ||
325 | case 32: | ||
326 | tmp |= (SMMR_MODE0 | SMMR_MODE1); | ||
327 | break; | ||
328 | default: | ||
329 | dev_err(dev->dev, "unsupported xfer size %d\n", dev->buf_len); | ||
330 | return -EINVAL; | ||
331 | } | ||
332 | |||
333 | iowrite16(tmp, dev->base + SMMR); | ||
334 | |||
335 | /* Ensure we're in a sane state */ | ||
336 | highlander_i2c_done(dev); | ||
337 | |||
338 | /* Set slave address */ | ||
339 | iowrite16((addr << 1) | read, dev->base + SMSMADR); | ||
340 | |||
341 | highlander_i2c_command(dev, command, dev->buf_len); | ||
342 | |||
343 | if (read) | ||
344 | return highlander_i2c_read(dev); | ||
345 | else | ||
346 | return highlander_i2c_write(dev); | ||
347 | } | ||
348 | |||
349 | static u32 highlander_i2c_func(struct i2c_adapter *adapter) | ||
350 | { | ||
351 | return I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_I2C_BLOCK; | ||
352 | } | ||
353 | |||
354 | static const struct i2c_algorithm highlander_i2c_algo = { | ||
355 | .smbus_xfer = highlander_i2c_smbus_xfer, | ||
356 | .functionality = highlander_i2c_func, | ||
357 | }; | ||
358 | |||
359 | static int __devinit highlander_i2c_probe(struct platform_device *pdev) | ||
360 | { | ||
361 | struct highlander_i2c_dev *dev; | ||
362 | struct i2c_adapter *adap; | ||
363 | struct resource *res; | ||
364 | int ret; | ||
365 | |||
366 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
367 | if (unlikely(!res)) { | ||
368 | dev_err(&pdev->dev, "no mem resource\n"); | ||
369 | return -ENODEV; | ||
370 | } | ||
371 | |||
372 | dev = kzalloc(sizeof(struct highlander_i2c_dev), GFP_KERNEL); | ||
373 | if (unlikely(!dev)) | ||
374 | return -ENOMEM; | ||
375 | |||
376 | dev->base = ioremap_nocache(res->start, res->end - res->start + 1); | ||
377 | if (unlikely(!dev->base)) { | ||
378 | ret = -ENXIO; | ||
379 | goto err; | ||
380 | } | ||
381 | |||
382 | dev->dev = &pdev->dev; | ||
383 | platform_set_drvdata(pdev, dev); | ||
384 | |||
385 | dev->irq = platform_get_irq(pdev, 0); | ||
386 | if (iic_force_poll) | ||
387 | dev->irq = 0; | ||
388 | |||
389 | if (dev->irq) { | ||
390 | ret = request_irq(dev->irq, highlander_i2c_irq, IRQF_DISABLED, | ||
391 | pdev->name, dev); | ||
392 | if (unlikely(ret)) | ||
393 | goto err_unmap; | ||
394 | |||
395 | highlander_i2c_irq_enable(dev); | ||
396 | } else { | ||
397 | dev_notice(&pdev->dev, "no IRQ, using polling mode\n"); | ||
398 | highlander_i2c_irq_disable(dev); | ||
399 | } | ||
400 | |||
401 | dev->last_read_time = jiffies; /* initial read jiffies */ | ||
402 | |||
403 | highlander_i2c_setup(dev); | ||
404 | |||
405 | adap = &dev->adapter; | ||
406 | i2c_set_adapdata(adap, dev); | ||
407 | adap->owner = THIS_MODULE; | ||
408 | adap->class = I2C_CLASS_HWMON; | ||
409 | strlcpy(adap->name, "HL FPGA I2C adapter", sizeof(adap->name)); | ||
410 | adap->algo = &highlander_i2c_algo; | ||
411 | adap->dev.parent = &pdev->dev; | ||
412 | adap->nr = pdev->id; | ||
413 | |||
414 | /* | ||
415 | * Reset the adapter | ||
416 | */ | ||
417 | ret = highlander_i2c_reset(dev); | ||
418 | if (unlikely(ret)) { | ||
419 | dev_err(&pdev->dev, "controller didn't come up\n"); | ||
420 | goto err_free_irq; | ||
421 | } | ||
422 | |||
423 | ret = i2c_add_numbered_adapter(adap); | ||
424 | if (unlikely(ret)) { | ||
425 | dev_err(&pdev->dev, "failure adding adapter\n"); | ||
426 | goto err_free_irq; | ||
427 | } | ||
428 | |||
429 | return 0; | ||
430 | |||
431 | err_free_irq: | ||
432 | if (dev->irq) | ||
433 | free_irq(dev->irq, dev); | ||
434 | err_unmap: | ||
435 | iounmap(dev->base); | ||
436 | err: | ||
437 | kfree(dev); | ||
438 | |||
439 | platform_set_drvdata(pdev, NULL); | ||
440 | |||
441 | return ret; | ||
442 | } | ||
443 | |||
444 | static int __devexit highlander_i2c_remove(struct platform_device *pdev) | ||
445 | { | ||
446 | struct highlander_i2c_dev *dev = platform_get_drvdata(pdev); | ||
447 | |||
448 | i2c_del_adapter(&dev->adapter); | ||
449 | |||
450 | if (dev->irq) | ||
451 | free_irq(dev->irq, dev); | ||
452 | |||
453 | iounmap(dev->base); | ||
454 | kfree(dev); | ||
455 | |||
456 | platform_set_drvdata(pdev, NULL); | ||
457 | |||
458 | return 0; | ||
459 | } | ||
460 | |||
461 | static struct platform_driver highlander_i2c_driver = { | ||
462 | .driver = { | ||
463 | .name = "i2c-highlander", | ||
464 | .owner = THIS_MODULE, | ||
465 | }, | ||
466 | |||
467 | .probe = highlander_i2c_probe, | ||
468 | .remove = __devexit_p(highlander_i2c_remove), | ||
469 | }; | ||
470 | |||
471 | static int __init highlander_i2c_init(void) | ||
472 | { | ||
473 | return platform_driver_register(&highlander_i2c_driver); | ||
474 | } | ||
475 | |||
476 | static void __exit highlander_i2c_exit(void) | ||
477 | { | ||
478 | platform_driver_unregister(&highlander_i2c_driver); | ||
479 | } | ||
480 | |||
481 | module_init(highlander_i2c_init); | ||
482 | module_exit(highlander_i2c_exit); | ||
483 | |||
484 | MODULE_AUTHOR("Paul Mundt"); | ||
485 | MODULE_DESCRIPTION("Renesas Highlander FPGA I2C/SMBus adapter"); | ||
486 | MODULE_LICENSE("GPL v2"); | ||
487 | |||
488 | module_param(iic_force_poll, bool, 0); | ||
489 | module_param(iic_force_normal, bool, 0); | ||
490 | module_param(iic_timeout, int, 0); | ||
491 | module_param(iic_read_delay, int, 0); | ||
492 | |||
493 | MODULE_PARM_DESC(iic_force_poll, "Force polling mode"); | ||
494 | MODULE_PARM_DESC(iic_force_normal, | ||
495 | "Force normal mode (100 kHz), default is fast mode (400 kHz)"); | ||
496 | MODULE_PARM_DESC(iic_timeout, "Set timeout value in msecs (default 1000 ms)"); | ||
497 | MODULE_PARM_DESC(iic_read_delay, | ||
498 | "Delay between data read cycles (default 0 ms)"); | ||
diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c index 1098f21ace13..648aa7baff83 100644 --- a/drivers/i2c/busses/i2c-hydra.c +++ b/drivers/i2c/busses/i2c-hydra.c | |||
@@ -123,7 +123,7 @@ static int __devinit hydra_probe(struct pci_dev *dev, | |||
123 | hydra_adap.name)) | 123 | hydra_adap.name)) |
124 | return -EBUSY; | 124 | return -EBUSY; |
125 | 125 | ||
126 | hydra_bit_data.data = ioremap(base, pci_resource_len(dev, 0)); | 126 | hydra_bit_data.data = pci_ioremap_bar(dev, 0); |
127 | if (hydra_bit_data.data == NULL) { | 127 | if (hydra_bit_data.data == NULL) { |
128 | release_mem_region(base+offsetof(struct Hydra, CachePD), 4); | 128 | release_mem_region(base+offsetof(struct Hydra, CachePD), 4); |
129 | return -ENODEV; | 129 | return -ENODEV; |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index dc7ea32b69a8..5123eb69a971 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -41,6 +41,7 @@ | |||
41 | Tolapai 0x5032 32 hard yes yes yes | 41 | Tolapai 0x5032 32 hard yes yes yes |
42 | ICH10 0x3a30 32 hard yes yes yes | 42 | ICH10 0x3a30 32 hard yes yes yes |
43 | ICH10 0x3a60 32 hard yes yes yes | 43 | ICH10 0x3a60 32 hard yes yes yes |
44 | PCH 0x3b30 32 hard yes yes yes | ||
44 | 45 | ||
45 | Features supported by this driver: | 46 | Features supported by this driver: |
46 | Software PEC no | 47 | Software PEC no |
@@ -576,6 +577,7 @@ static struct pci_device_id i801_ids[] = { | |||
576 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TOLAPAI_1) }, | 577 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TOLAPAI_1) }, |
577 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_4) }, | 578 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_4) }, |
578 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_5) }, | 579 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_5) }, |
580 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PCH_SMBUS) }, | ||
579 | { 0, } | 581 | { 0, } |
580 | }; | 582 | }; |
581 | 583 | ||
@@ -599,6 +601,7 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id | |||
599 | case PCI_DEVICE_ID_INTEL_TOLAPAI_1: | 601 | case PCI_DEVICE_ID_INTEL_TOLAPAI_1: |
600 | case PCI_DEVICE_ID_INTEL_ICH10_4: | 602 | case PCI_DEVICE_ID_INTEL_ICH10_4: |
601 | case PCI_DEVICE_ID_INTEL_ICH10_5: | 603 | case PCI_DEVICE_ID_INTEL_ICH10_5: |
604 | case PCI_DEVICE_ID_INTEL_PCH_SMBUS: | ||
602 | i801_features |= FEATURE_I2C_BLOCK_READ; | 605 | i801_features |= FEATURE_I2C_BLOCK_READ; |
603 | /* fall through */ | 606 | /* fall through */ |
604 | case PCI_DEVICE_ID_INTEL_82801DB_3: | 607 | case PCI_DEVICE_ID_INTEL_82801DB_3: |
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-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 27443f073bc9..a9a45fcc8544 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -312,7 +312,6 @@ static struct i2c_adapter mpc_ops = { | |||
312 | .name = "MPC adapter", | 312 | .name = "MPC adapter", |
313 | .id = I2C_HW_MPC107, | 313 | .id = I2C_HW_MPC107, |
314 | .algo = &mpc_algo, | 314 | .algo = &mpc_algo, |
315 | .class = I2C_CLASS_HWMON | I2C_CLASS_SPD, | ||
316 | .timeout = 1, | 315 | .timeout = 1, |
317 | }; | 316 | }; |
318 | 317 | ||
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-omap.c b/drivers/i2c/busses/i2c-omap.c index e7eb7bf9ddec..608038d64f81 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c | |||
@@ -589,11 +589,16 @@ omap_i2c_probe(struct platform_device *pdev) | |||
589 | 589 | ||
590 | dev->dev = &pdev->dev; | 590 | dev->dev = &pdev->dev; |
591 | dev->irq = irq->start; | 591 | dev->irq = irq->start; |
592 | dev->base = (void __iomem *) IO_ADDRESS(mem->start); | 592 | dev->base = ioremap(mem->start, mem->end - mem->start + 1); |
593 | if (!dev->base) { | ||
594 | r = -ENOMEM; | ||
595 | goto err_free_mem; | ||
596 | } | ||
597 | |||
593 | platform_set_drvdata(pdev, dev); | 598 | platform_set_drvdata(pdev, dev); |
594 | 599 | ||
595 | if ((r = omap_i2c_get_clocks(dev)) != 0) | 600 | if ((r = omap_i2c_get_clocks(dev)) != 0) |
596 | goto err_free_mem; | 601 | goto err_iounmap; |
597 | 602 | ||
598 | omap_i2c_unidle(dev); | 603 | omap_i2c_unidle(dev); |
599 | 604 | ||
@@ -640,6 +645,8 @@ err_unuse_clocks: | |||
640 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); | 645 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); |
641 | omap_i2c_idle(dev); | 646 | omap_i2c_idle(dev); |
642 | omap_i2c_put_clocks(dev); | 647 | omap_i2c_put_clocks(dev); |
648 | err_iounmap: | ||
649 | iounmap(dev->base); | ||
643 | err_free_mem: | 650 | err_free_mem: |
644 | platform_set_drvdata(pdev, NULL); | 651 | platform_set_drvdata(pdev, NULL); |
645 | kfree(dev); | 652 | kfree(dev); |
@@ -661,6 +668,7 @@ omap_i2c_remove(struct platform_device *pdev) | |||
661 | i2c_del_adapter(&dev->adapter); | 668 | i2c_del_adapter(&dev->adapter); |
662 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); | 669 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); |
663 | omap_i2c_put_clocks(dev); | 670 | omap_i2c_put_clocks(dev); |
671 | iounmap(dev->base); | ||
664 | kfree(dev); | 672 | kfree(dev); |
665 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 673 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
666 | release_mem_region(mem->start, (mem->end - mem->start) + 1); | 674 | release_mem_region(mem->start, (mem->end - mem->start) + 1); |
diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c index c6faf9bdad18..b2b8380f6602 100644 --- a/drivers/i2c/busses/i2c-parport-light.c +++ b/drivers/i2c/busses/i2c-parport-light.c | |||
@@ -123,11 +123,6 @@ static struct i2c_adapter parport_adapter = { | |||
123 | static int __devinit i2c_parport_probe(struct platform_device *pdev) | 123 | static int __devinit i2c_parport_probe(struct platform_device *pdev) |
124 | { | 124 | { |
125 | int err; | 125 | int err; |
126 | struct resource *res; | ||
127 | |||
128 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
129 | if (!request_region(res->start, res->end - res->start + 1, DRVNAME)) | ||
130 | return -EBUSY; | ||
131 | 126 | ||
132 | /* Reset hardware to a sane state (SCL and SDA high) */ | 127 | /* Reset hardware to a sane state (SCL and SDA high) */ |
133 | parport_setsda(NULL, 1); | 128 | parport_setsda(NULL, 1); |
@@ -138,29 +133,19 @@ static int __devinit i2c_parport_probe(struct platform_device *pdev) | |||
138 | 133 | ||
139 | parport_adapter.dev.parent = &pdev->dev; | 134 | parport_adapter.dev.parent = &pdev->dev; |
140 | err = i2c_bit_add_bus(&parport_adapter); | 135 | err = i2c_bit_add_bus(&parport_adapter); |
141 | if (err) { | 136 | if (err) |
142 | dev_err(&pdev->dev, "Unable to register with I2C\n"); | 137 | dev_err(&pdev->dev, "Unable to register with I2C\n"); |
143 | goto exit_region; | ||
144 | } | ||
145 | return 0; | ||
146 | |||
147 | exit_region: | ||
148 | release_region(res->start, res->end - res->start + 1); | ||
149 | return err; | 138 | return err; |
150 | } | 139 | } |
151 | 140 | ||
152 | static int __devexit i2c_parport_remove(struct platform_device *pdev) | 141 | static int __devexit i2c_parport_remove(struct platform_device *pdev) |
153 | { | 142 | { |
154 | struct resource *res; | ||
155 | |||
156 | i2c_del_adapter(&parport_adapter); | 143 | i2c_del_adapter(&parport_adapter); |
157 | 144 | ||
158 | /* Un-init if needed (power off...) */ | 145 | /* Un-init if needed (power off...) */ |
159 | if (adapter_parm[type].init.val) | 146 | if (adapter_parm[type].init.val) |
160 | line_set(0, &adapter_parm[type].init); | 147 | line_set(0, &adapter_parm[type].init); |
161 | 148 | ||
162 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
163 | release_region(res->start, res->end - res->start + 1); | ||
164 | return 0; | 149 | return 0; |
165 | } | 150 | } |
166 | 151 | ||
@@ -175,12 +160,6 @@ static struct platform_driver i2c_parport_driver = { | |||
175 | 160 | ||
176 | static int __init i2c_parport_device_add(u16 address) | 161 | static int __init i2c_parport_device_add(u16 address) |
177 | { | 162 | { |
178 | struct resource res = { | ||
179 | .start = address, | ||
180 | .end = address + 2, | ||
181 | .name = DRVNAME, | ||
182 | .flags = IORESOURCE_IO, | ||
183 | }; | ||
184 | int err; | 163 | int err; |
185 | 164 | ||
186 | pdev = platform_device_alloc(DRVNAME, -1); | 165 | pdev = platform_device_alloc(DRVNAME, -1); |
@@ -190,13 +169,6 @@ static int __init i2c_parport_device_add(u16 address) | |||
190 | goto exit; | 169 | goto exit; |
191 | } | 170 | } |
192 | 171 | ||
193 | err = platform_device_add_resources(pdev, &res, 1); | ||
194 | if (err) { | ||
195 | printk(KERN_ERR DRVNAME ": Device resource addition failed " | ||
196 | "(%d)\n", err); | ||
197 | goto exit_device_put; | ||
198 | } | ||
199 | |||
200 | err = platform_device_add(pdev); | 172 | err = platform_device_add(pdev); |
201 | if (err) { | 173 | if (err) { |
202 | printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n", | 174 | printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n", |
@@ -231,13 +203,16 @@ static int __init i2c_parport_init(void) | |||
231 | base = DEFAULT_BASE; | 203 | base = DEFAULT_BASE; |
232 | } | 204 | } |
233 | 205 | ||
206 | if (!request_region(base, 3, DRVNAME)) | ||
207 | return -EBUSY; | ||
208 | |||
234 | if (!adapter_parm[type].getscl.val) | 209 | if (!adapter_parm[type].getscl.val) |
235 | parport_algo_data.getscl = NULL; | 210 | parport_algo_data.getscl = NULL; |
236 | 211 | ||
237 | /* Sets global pdev as a side effect */ | 212 | /* Sets global pdev as a side effect */ |
238 | err = i2c_parport_device_add(base); | 213 | err = i2c_parport_device_add(base); |
239 | if (err) | 214 | if (err) |
240 | goto exit; | 215 | goto exit_release; |
241 | 216 | ||
242 | err = platform_driver_register(&i2c_parport_driver); | 217 | err = platform_driver_register(&i2c_parport_driver); |
243 | if (err) | 218 | if (err) |
@@ -247,7 +222,8 @@ static int __init i2c_parport_init(void) | |||
247 | 222 | ||
248 | exit_device: | 223 | exit_device: |
249 | platform_device_unregister(pdev); | 224 | platform_device_unregister(pdev); |
250 | exit: | 225 | exit_release: |
226 | release_region(base, 3); | ||
251 | return err; | 227 | return err; |
252 | } | 228 | } |
253 | 229 | ||
@@ -255,6 +231,7 @@ static void __exit i2c_parport_exit(void) | |||
255 | { | 231 | { |
256 | platform_driver_unregister(&i2c_parport_driver); | 232 | platform_driver_unregister(&i2c_parport_driver); |
257 | platform_device_unregister(pdev); | 233 | platform_device_unregister(pdev); |
234 | release_region(base, 3); | ||
258 | } | 235 | } |
259 | 236 | ||
260 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); | 237 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); |
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c index a119784bae10..9eb76268ec78 100644 --- a/drivers/i2c/busses/i2c-pca-isa.c +++ b/drivers/i2c/busses/i2c-pca-isa.c | |||
@@ -36,8 +36,8 @@ | |||
36 | #define DRIVER "i2c-pca-isa" | 36 | #define DRIVER "i2c-pca-isa" |
37 | #define IO_SIZE 4 | 37 | #define IO_SIZE 4 |
38 | 38 | ||
39 | static unsigned long base = 0x330; | 39 | static unsigned long base; |
40 | static int irq = 10; | 40 | static int irq = -1; |
41 | 41 | ||
42 | /* Data sheet recommends 59kHz for 100kHz operation due to variation | 42 | /* Data sheet recommends 59kHz for 100kHz operation due to variation |
43 | * in the actual clock rate */ | 43 | * in the actual clock rate */ |
@@ -107,13 +107,26 @@ static struct i2c_adapter pca_isa_ops = { | |||
107 | .timeout = 100, | 107 | .timeout = 100, |
108 | }; | 108 | }; |
109 | 109 | ||
110 | static int __devinit pca_isa_match(struct device *dev, unsigned int id) | ||
111 | { | ||
112 | int match = base != 0; | ||
113 | |||
114 | if (match) { | ||
115 | if (irq <= -1) | ||
116 | dev_warn(dev, "Using polling mode (specify irq)\n"); | ||
117 | } else | ||
118 | dev_err(dev, "Please specify I/O base\n"); | ||
119 | |||
120 | return match; | ||
121 | } | ||
122 | |||
110 | static int __devinit pca_isa_probe(struct device *dev, unsigned int id) | 123 | static int __devinit pca_isa_probe(struct device *dev, unsigned int id) |
111 | { | 124 | { |
112 | init_waitqueue_head(&pca_wait); | 125 | init_waitqueue_head(&pca_wait); |
113 | 126 | ||
114 | dev_info(dev, "i/o base %#08lx. irq %d\n", base, irq); | 127 | dev_info(dev, "i/o base %#08lx. irq %d\n", base, irq); |
115 | 128 | ||
116 | #ifdef CONFIG_PPC_MERGE | 129 | #ifdef CONFIG_PPC |
117 | if (check_legacy_ioport(base)) { | 130 | if (check_legacy_ioport(base)) { |
118 | dev_err(dev, "I/O address %#08lx is not available\n", base); | 131 | dev_err(dev, "I/O address %#08lx is not available\n", base); |
119 | goto out; | 132 | goto out; |
@@ -153,7 +166,7 @@ static int __devexit pca_isa_remove(struct device *dev, unsigned int id) | |||
153 | { | 166 | { |
154 | i2c_del_adapter(&pca_isa_ops); | 167 | i2c_del_adapter(&pca_isa_ops); |
155 | 168 | ||
156 | if (irq > 0) { | 169 | if (irq > -1) { |
157 | disable_irq(irq); | 170 | disable_irq(irq); |
158 | free_irq(irq, &pca_isa_ops); | 171 | free_irq(irq, &pca_isa_ops); |
159 | } | 172 | } |
@@ -163,6 +176,7 @@ static int __devexit pca_isa_remove(struct device *dev, unsigned int id) | |||
163 | } | 176 | } |
164 | 177 | ||
165 | static struct isa_driver pca_isa_driver = { | 178 | static struct isa_driver pca_isa_driver = { |
179 | .match = pca_isa_match, | ||
166 | .probe = pca_isa_probe, | 180 | .probe = pca_isa_probe, |
167 | .remove = __devexit_p(pca_isa_remove), | 181 | .remove = __devexit_p(pca_isa_remove), |
168 | .driver = { | 182 | .driver = { |
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-powermac.c b/drivers/i2c/busses/i2c-powermac.c index 22f6d5c00d80..60ca91745e55 100644 --- a/drivers/i2c/busses/i2c-powermac.c +++ b/drivers/i2c/busses/i2c-powermac.c | |||
@@ -180,7 +180,7 @@ static const struct i2c_algorithm i2c_powermac_algorithm = { | |||
180 | }; | 180 | }; |
181 | 181 | ||
182 | 182 | ||
183 | static int i2c_powermac_remove(struct platform_device *dev) | 183 | static int __devexit i2c_powermac_remove(struct platform_device *dev) |
184 | { | 184 | { |
185 | struct i2c_adapter *adapter = platform_get_drvdata(dev); | 185 | struct i2c_adapter *adapter = platform_get_drvdata(dev); |
186 | struct pmac_i2c_bus *bus = i2c_get_adapdata(adapter); | 186 | struct pmac_i2c_bus *bus = i2c_get_adapdata(adapter); |
@@ -200,7 +200,7 @@ static int i2c_powermac_remove(struct platform_device *dev) | |||
200 | } | 200 | } |
201 | 201 | ||
202 | 202 | ||
203 | static int __devexit i2c_powermac_probe(struct platform_device *dev) | 203 | static int __devinit i2c_powermac_probe(struct platform_device *dev) |
204 | { | 204 | { |
205 | struct pmac_i2c_bus *bus = dev->dev.platform_data; | 205 | struct pmac_i2c_bus *bus = dev->dev.platform_data; |
206 | struct device_node *parent = NULL; | 206 | struct device_node *parent = NULL; |
@@ -259,6 +259,35 @@ static int __devexit i2c_powermac_probe(struct platform_device *dev) | |||
259 | } | 259 | } |
260 | 260 | ||
261 | printk(KERN_INFO "PowerMac i2c bus %s registered\n", name); | 261 | printk(KERN_INFO "PowerMac i2c bus %s registered\n", name); |
262 | |||
263 | if (!strncmp(basename, "uni-n", 5)) { | ||
264 | struct device_node *np; | ||
265 | const u32 *prop; | ||
266 | struct i2c_board_info info; | ||
267 | |||
268 | /* Instantiate I2C motion sensor if present */ | ||
269 | np = of_find_node_by_name(NULL, "accelerometer"); | ||
270 | if (np && of_device_is_compatible(np, "AAPL,accelerometer_1") && | ||
271 | (prop = of_get_property(np, "reg", NULL))) { | ||
272 | int i2c_bus; | ||
273 | const char *tmp_bus; | ||
274 | |||
275 | /* look for bus either using "reg" or by path */ | ||
276 | tmp_bus = strstr(np->full_name, "/i2c-bus@"); | ||
277 | if (tmp_bus) | ||
278 | i2c_bus = *(tmp_bus + 9) - '0'; | ||
279 | else | ||
280 | i2c_bus = ((*prop) >> 8) & 0x0f; | ||
281 | |||
282 | if (pmac_i2c_get_channel(bus) == i2c_bus) { | ||
283 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
284 | info.addr = ((*prop) & 0xff) >> 1; | ||
285 | strlcpy(info.type, "ams", I2C_NAME_SIZE); | ||
286 | i2c_new_device(adapter, &info); | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | |||
262 | return rc; | 291 | return rc; |
263 | } | 292 | } |
264 | 293 | ||
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index af9e6034d7fb..906f9b9d715d 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
@@ -34,11 +34,48 @@ | |||
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 | |
42 | /* | ||
43 | * I2C registers and bit definitions | ||
44 | */ | ||
45 | #define IBMR (0x00) | ||
46 | #define IDBR (0x08) | ||
47 | #define ICR (0x10) | ||
48 | #define ISR (0x18) | ||
49 | #define ISAR (0x20) | ||
50 | |||
51 | #define ICR_START (1 << 0) /* start bit */ | ||
52 | #define ICR_STOP (1 << 1) /* stop bit */ | ||
53 | #define ICR_ACKNAK (1 << 2) /* send ACK(0) or NAK(1) */ | ||
54 | #define ICR_TB (1 << 3) /* transfer byte bit */ | ||
55 | #define ICR_MA (1 << 4) /* master abort */ | ||
56 | #define ICR_SCLE (1 << 5) /* master clock enable */ | ||
57 | #define ICR_IUE (1 << 6) /* unit enable */ | ||
58 | #define ICR_GCD (1 << 7) /* general call disable */ | ||
59 | #define ICR_ITEIE (1 << 8) /* enable tx interrupts */ | ||
60 | #define ICR_IRFIE (1 << 9) /* enable rx interrupts */ | ||
61 | #define ICR_BEIE (1 << 10) /* enable bus error ints */ | ||
62 | #define ICR_SSDIE (1 << 11) /* slave STOP detected int enable */ | ||
63 | #define ICR_ALDIE (1 << 12) /* enable arbitration interrupt */ | ||
64 | #define ICR_SADIE (1 << 13) /* slave address detected int enable */ | ||
65 | #define ICR_UR (1 << 14) /* unit reset */ | ||
66 | #define ICR_FM (1 << 15) /* fast mode */ | ||
67 | |||
68 | #define ISR_RWM (1 << 0) /* read/write mode */ | ||
69 | #define ISR_ACKNAK (1 << 1) /* ack/nak status */ | ||
70 | #define ISR_UB (1 << 2) /* unit busy */ | ||
71 | #define ISR_IBB (1 << 3) /* bus busy */ | ||
72 | #define ISR_SSD (1 << 4) /* slave stop detected */ | ||
73 | #define ISR_ALD (1 << 5) /* arbitration loss detected */ | ||
74 | #define ISR_ITE (1 << 6) /* tx buffer empty */ | ||
75 | #define ISR_IRF (1 << 7) /* rx buffer full */ | ||
76 | #define ISR_GCAD (1 << 8) /* general call address detected */ | ||
77 | #define ISR_SAD (1 << 9) /* slave address detected */ | ||
78 | #define ISR_BED (1 << 10) /* bus error no ACK/NAK */ | ||
42 | 79 | ||
43 | struct pxa_i2c { | 80 | struct pxa_i2c { |
44 | spinlock_t lock; | 81 | spinlock_t lock; |
@@ -60,19 +97,21 @@ struct pxa_i2c { | |||
60 | u32 icrlog[32]; | 97 | u32 icrlog[32]; |
61 | 98 | ||
62 | void __iomem *reg_base; | 99 | void __iomem *reg_base; |
100 | unsigned int reg_shift; | ||
63 | 101 | ||
64 | unsigned long iobase; | 102 | unsigned long iobase; |
65 | unsigned long iosize; | 103 | unsigned long iosize; |
66 | 104 | ||
67 | int irq; | 105 | int irq; |
68 | int use_pio; | 106 | unsigned int use_pio :1; |
107 | unsigned int fast_mode :1; | ||
69 | }; | 108 | }; |
70 | 109 | ||
71 | #define _IBMR(i2c) ((i2c)->reg_base + 0) | 110 | #define _IBMR(i2c) ((i2c)->reg_base + (0x0 << (i2c)->reg_shift)) |
72 | #define _IDBR(i2c) ((i2c)->reg_base + 8) | 111 | #define _IDBR(i2c) ((i2c)->reg_base + (0x4 << (i2c)->reg_shift)) |
73 | #define _ICR(i2c) ((i2c)->reg_base + 0x10) | 112 | #define _ICR(i2c) ((i2c)->reg_base + (0x8 << (i2c)->reg_shift)) |
74 | #define _ISR(i2c) ((i2c)->reg_base + 0x18) | 113 | #define _ISR(i2c) ((i2c)->reg_base + (0xc << (i2c)->reg_shift)) |
75 | #define _ISAR(i2c) ((i2c)->reg_base + 0x20) | 114 | #define _ISAR(i2c) ((i2c)->reg_base + (0x10 << (i2c)->reg_shift)) |
76 | 115 | ||
77 | /* | 116 | /* |
78 | * I2C Slave mode address | 117 | * I2C Slave mode address |
@@ -188,14 +227,14 @@ static inline int i2c_pxa_is_slavemode(struct pxa_i2c *i2c) | |||
188 | 227 | ||
189 | static void i2c_pxa_abort(struct pxa_i2c *i2c) | 228 | static void i2c_pxa_abort(struct pxa_i2c *i2c) |
190 | { | 229 | { |
191 | unsigned long timeout = jiffies + HZ/4; | 230 | int i = 250; |
192 | 231 | ||
193 | if (i2c_pxa_is_slavemode(i2c)) { | 232 | if (i2c_pxa_is_slavemode(i2c)) { |
194 | dev_dbg(&i2c->adap.dev, "%s: called in slave mode\n", __func__); | 233 | dev_dbg(&i2c->adap.dev, "%s: called in slave mode\n", __func__); |
195 | return; | 234 | return; |
196 | } | 235 | } |
197 | 236 | ||
198 | while (time_before(jiffies, timeout) && (readl(_IBMR(i2c)) & 0x1) == 0) { | 237 | while ((i > 0) && (readl(_IBMR(i2c)) & 0x1) == 0) { |
199 | unsigned long icr = readl(_ICR(i2c)); | 238 | unsigned long icr = readl(_ICR(i2c)); |
200 | 239 | ||
201 | icr &= ~ICR_START; | 240 | icr &= ~ICR_START; |
@@ -205,7 +244,8 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c) | |||
205 | 244 | ||
206 | show_state(i2c); | 245 | show_state(i2c); |
207 | 246 | ||
208 | msleep(1); | 247 | mdelay(1); |
248 | i --; | ||
209 | } | 249 | } |
210 | 250 | ||
211 | writel(readl(_ICR(i2c)) & ~(ICR_MA | ICR_START | ICR_STOP), | 251 | writel(readl(_ICR(i2c)) & ~(ICR_MA | ICR_START | ICR_STOP), |
@@ -364,7 +404,7 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c) | |||
364 | writel(i2c->slave_addr, _ISAR(i2c)); | 404 | writel(i2c->slave_addr, _ISAR(i2c)); |
365 | 405 | ||
366 | /* set control register values */ | 406 | /* set control register values */ |
367 | writel(I2C_ICR_INIT, _ICR(i2c)); | 407 | writel(I2C_ICR_INIT | (i2c->fast_mode ? ICR_FM : 0), _ICR(i2c)); |
368 | 408 | ||
369 | #ifdef CONFIG_I2C_PXA_SLAVE | 409 | #ifdef CONFIG_I2C_PXA_SLAVE |
370 | dev_info(&i2c->adap.dev, "Enabling slave mode\n"); | 410 | dev_info(&i2c->adap.dev, "Enabling slave mode\n"); |
@@ -907,12 +947,6 @@ static int i2c_pxa_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num | |||
907 | struct pxa_i2c *i2c = adap->algo_data; | 947 | struct pxa_i2c *i2c = adap->algo_data; |
908 | int ret, i; | 948 | int ret, i; |
909 | 949 | ||
910 | /* If the I2C controller is disabled we need to reset it (probably due | ||
911 | to a suspend/resume destroying state). We do this here as we can then | ||
912 | avoid worrying about resuming the controller before its users. */ | ||
913 | if (!(readl(_ICR(i2c)) & ICR_IUE)) | ||
914 | i2c_pxa_reset(i2c); | ||
915 | |||
916 | for (i = adap->retries; i >= 0; i--) { | 950 | for (i = adap->retries; i >= 0; i--) { |
917 | ret = i2c_pxa_do_xfer(i2c, msgs, num); | 951 | ret = i2c_pxa_do_xfer(i2c, msgs, num); |
918 | if (ret != I2C_RETRY) | 952 | if (ret != I2C_RETRY) |
@@ -993,6 +1027,7 @@ static int i2c_pxa_probe(struct platform_device *dev) | |||
993 | ret = -EIO; | 1027 | ret = -EIO; |
994 | goto eremap; | 1028 | goto eremap; |
995 | } | 1029 | } |
1030 | i2c->reg_shift = (cpu_is_pxa3xx() && (dev->id == 1)) ? 0 : 1; | ||
996 | 1031 | ||
997 | i2c->iobase = res->start; | 1032 | i2c->iobase = res->start; |
998 | i2c->iosize = res_len(res); | 1033 | i2c->iosize = res_len(res); |
@@ -1013,6 +1048,7 @@ static int i2c_pxa_probe(struct platform_device *dev) | |||
1013 | if (plat) { | 1048 | if (plat) { |
1014 | i2c->adap.class = plat->class; | 1049 | i2c->adap.class = plat->class; |
1015 | i2c->use_pio = plat->use_pio; | 1050 | i2c->use_pio = plat->use_pio; |
1051 | i2c->fast_mode = plat->fast_mode; | ||
1016 | } | 1052 | } |
1017 | 1053 | ||
1018 | if (i2c->use_pio) { | 1054 | if (i2c->use_pio) { |
@@ -1082,9 +1118,33 @@ static int __exit i2c_pxa_remove(struct platform_device *dev) | |||
1082 | return 0; | 1118 | return 0; |
1083 | } | 1119 | } |
1084 | 1120 | ||
1121 | #ifdef CONFIG_PM | ||
1122 | static int i2c_pxa_suspend_late(struct platform_device *dev, pm_message_t state) | ||
1123 | { | ||
1124 | struct pxa_i2c *i2c = platform_get_drvdata(dev); | ||
1125 | clk_disable(i2c->clk); | ||
1126 | return 0; | ||
1127 | } | ||
1128 | |||
1129 | static int i2c_pxa_resume_early(struct platform_device *dev) | ||
1130 | { | ||
1131 | struct pxa_i2c *i2c = platform_get_drvdata(dev); | ||
1132 | |||
1133 | clk_enable(i2c->clk); | ||
1134 | i2c_pxa_reset(i2c); | ||
1135 | |||
1136 | return 0; | ||
1137 | } | ||
1138 | #else | ||
1139 | #define i2c_pxa_suspend_late NULL | ||
1140 | #define i2c_pxa_resume_early NULL | ||
1141 | #endif | ||
1142 | |||
1085 | static struct platform_driver i2c_pxa_driver = { | 1143 | static struct platform_driver i2c_pxa_driver = { |
1086 | .probe = i2c_pxa_probe, | 1144 | .probe = i2c_pxa_probe, |
1087 | .remove = __exit_p(i2c_pxa_remove), | 1145 | .remove = __exit_p(i2c_pxa_remove), |
1146 | .suspend_late = i2c_pxa_suspend_late, | ||
1147 | .resume_early = i2c_pxa_resume_early, | ||
1088 | .driver = { | 1148 | .driver = { |
1089 | .name = "pxa2xx-i2c", | 1149 | .name = "pxa2xx-i2c", |
1090 | .owner = THIS_MODULE, | 1150 | .owner = THIS_MODULE, |
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/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 840e634fa31f..640cbb237328 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c | |||
@@ -31,13 +31,84 @@ | |||
31 | #include <linux/clk.h> | 31 | #include <linux/clk.h> |
32 | #include <linux/io.h> | 32 | #include <linux/io.h> |
33 | 33 | ||
34 | /* Transmit operation: */ | ||
35 | /* */ | ||
36 | /* 0 byte transmit */ | ||
37 | /* BUS: S A8 ACK P */ | ||
38 | /* IRQ: DTE WAIT */ | ||
39 | /* ICIC: */ | ||
40 | /* ICCR: 0x94 0x90 */ | ||
41 | /* ICDR: A8 */ | ||
42 | /* */ | ||
43 | /* 1 byte transmit */ | ||
44 | /* BUS: S A8 ACK D8(1) ACK P */ | ||
45 | /* IRQ: DTE WAIT WAIT */ | ||
46 | /* ICIC: -DTE */ | ||
47 | /* ICCR: 0x94 0x90 */ | ||
48 | /* ICDR: A8 D8(1) */ | ||
49 | /* */ | ||
50 | /* 2 byte transmit */ | ||
51 | /* BUS: S A8 ACK D8(1) ACK D8(2) ACK P */ | ||
52 | /* IRQ: DTE WAIT WAIT WAIT */ | ||
53 | /* ICIC: -DTE */ | ||
54 | /* ICCR: 0x94 0x90 */ | ||
55 | /* ICDR: A8 D8(1) D8(2) */ | ||
56 | /* */ | ||
57 | /* 3 bytes or more, +---------+ gets repeated */ | ||
58 | /* */ | ||
59 | /* */ | ||
60 | /* Receive operation: */ | ||
61 | /* */ | ||
62 | /* 0 byte receive - not supported since slave may hold SDA low */ | ||
63 | /* */ | ||
64 | /* 1 byte receive [TX] | [RX] */ | ||
65 | /* BUS: S A8 ACK | D8(1) ACK P */ | ||
66 | /* IRQ: DTE WAIT | WAIT DTE */ | ||
67 | /* ICIC: -DTE | +DTE */ | ||
68 | /* ICCR: 0x94 0x81 | 0xc0 */ | ||
69 | /* ICDR: A8 | D8(1) */ | ||
70 | /* */ | ||
71 | /* 2 byte receive [TX]| [RX] */ | ||
72 | /* BUS: S A8 ACK | D8(1) ACK D8(2) ACK P */ | ||
73 | /* IRQ: DTE WAIT | WAIT WAIT DTE */ | ||
74 | /* ICIC: -DTE | +DTE */ | ||
75 | /* ICCR: 0x94 0x81 | 0xc0 */ | ||
76 | /* ICDR: A8 | D8(1) D8(2) */ | ||
77 | /* */ | ||
78 | /* 3 byte receive [TX] | [RX] */ | ||
79 | /* BUS: S A8 ACK | D8(1) ACK D8(2) ACK D8(3) ACK P */ | ||
80 | /* IRQ: DTE WAIT | WAIT WAIT WAIT DTE */ | ||
81 | /* ICIC: -DTE | +DTE */ | ||
82 | /* ICCR: 0x94 0x81 | 0xc0 */ | ||
83 | /* ICDR: A8 | D8(1) D8(2) D8(3) */ | ||
84 | /* */ | ||
85 | /* 4 bytes or more, this part is repeated +---------+ */ | ||
86 | /* */ | ||
87 | /* */ | ||
88 | /* Interrupt order and BUSY flag */ | ||
89 | /* ___ _ */ | ||
90 | /* SDA ___\___XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXAAAAAAAAA___/ */ | ||
91 | /* SCL \_/1\_/2\_/3\_/4\_/5\_/6\_/7\_/8\___/9\_____/ */ | ||
92 | /* */ | ||
93 | /* S D7 D6 D5 D4 D3 D2 D1 D0 P */ | ||
94 | /* ___ */ | ||
95 | /* WAIT IRQ ________________________________/ \___________ */ | ||
96 | /* TACK IRQ ____________________________________/ \_______ */ | ||
97 | /* DTE IRQ __________________________________________/ \_ */ | ||
98 | /* AL IRQ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ | ||
99 | /* _______________________________________________ */ | ||
100 | /* BUSY __/ \_ */ | ||
101 | /* */ | ||
102 | |||
34 | enum sh_mobile_i2c_op { | 103 | enum sh_mobile_i2c_op { |
35 | OP_START = 0, | 104 | OP_START = 0, |
36 | OP_TX_ONLY, | 105 | OP_TX_FIRST, |
106 | OP_TX, | ||
37 | OP_TX_STOP, | 107 | OP_TX_STOP, |
38 | OP_TX_TO_RX, | 108 | OP_TX_TO_RX, |
39 | OP_RX_ONLY, | 109 | OP_RX, |
40 | OP_RX_STOP, | 110 | OP_RX_STOP, |
111 | OP_RX_STOP_DATA, | ||
41 | }; | 112 | }; |
42 | 113 | ||
43 | struct sh_mobile_i2c_data { | 114 | struct sh_mobile_i2c_data { |
@@ -127,25 +198,34 @@ static unsigned char i2c_op(struct sh_mobile_i2c_data *pd, | |||
127 | spin_lock_irqsave(&pd->lock, flags); | 198 | spin_lock_irqsave(&pd->lock, flags); |
128 | 199 | ||
129 | switch (op) { | 200 | switch (op) { |
130 | case OP_START: | 201 | case OP_START: /* issue start and trigger DTE interrupt */ |
131 | iowrite8(0x94, ICCR(pd)); | 202 | iowrite8(0x94, ICCR(pd)); |
132 | break; | 203 | break; |
133 | case OP_TX_ONLY: | 204 | case OP_TX_FIRST: /* disable DTE interrupt and write data */ |
205 | iowrite8(ICIC_WAITE | ICIC_ALE | ICIC_TACKE, ICIC(pd)); | ||
134 | iowrite8(data, ICDR(pd)); | 206 | iowrite8(data, ICDR(pd)); |
135 | break; | 207 | break; |
136 | case OP_TX_STOP: | 208 | case OP_TX: /* write data */ |
137 | iowrite8(data, ICDR(pd)); | 209 | iowrite8(data, ICDR(pd)); |
138 | iowrite8(0x90, ICCR(pd)); | ||
139 | iowrite8(ICIC_ALE | ICIC_TACKE, ICIC(pd)); | ||
140 | break; | 210 | break; |
141 | case OP_TX_TO_RX: | 211 | case OP_TX_STOP: /* write data and issue a stop afterwards */ |
142 | iowrite8(data, ICDR(pd)); | 212 | iowrite8(data, ICDR(pd)); |
213 | iowrite8(0x90, ICCR(pd)); | ||
214 | break; | ||
215 | case OP_TX_TO_RX: /* select read mode */ | ||
143 | iowrite8(0x81, ICCR(pd)); | 216 | iowrite8(0x81, ICCR(pd)); |
144 | break; | 217 | break; |
145 | case OP_RX_ONLY: | 218 | case OP_RX: /* just read data */ |
146 | ret = ioread8(ICDR(pd)); | 219 | ret = ioread8(ICDR(pd)); |
147 | break; | 220 | break; |
148 | case OP_RX_STOP: | 221 | case OP_RX_STOP: /* enable DTE interrupt, issue stop */ |
222 | iowrite8(ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE, | ||
223 | ICIC(pd)); | ||
224 | iowrite8(0xc0, ICCR(pd)); | ||
225 | break; | ||
226 | case OP_RX_STOP_DATA: /* enable DTE interrupt, read data, issue stop */ | ||
227 | iowrite8(ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE, | ||
228 | ICIC(pd)); | ||
149 | ret = ioread8(ICDR(pd)); | 229 | ret = ioread8(ICDR(pd)); |
150 | iowrite8(0xc0, ICCR(pd)); | 230 | iowrite8(0xc0, ICCR(pd)); |
151 | break; | 231 | break; |
@@ -157,58 +237,120 @@ static unsigned char i2c_op(struct sh_mobile_i2c_data *pd, | |||
157 | return ret; | 237 | return ret; |
158 | } | 238 | } |
159 | 239 | ||
240 | static int sh_mobile_i2c_is_first_byte(struct sh_mobile_i2c_data *pd) | ||
241 | { | ||
242 | if (pd->pos == -1) | ||
243 | return 1; | ||
244 | |||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | static int sh_mobile_i2c_is_last_byte(struct sh_mobile_i2c_data *pd) | ||
249 | { | ||
250 | if (pd->pos == (pd->msg->len - 1)) | ||
251 | return 1; | ||
252 | |||
253 | return 0; | ||
254 | } | ||
255 | |||
256 | static void sh_mobile_i2c_get_data(struct sh_mobile_i2c_data *pd, | ||
257 | unsigned char *buf) | ||
258 | { | ||
259 | switch (pd->pos) { | ||
260 | case -1: | ||
261 | *buf = (pd->msg->addr & 0x7f) << 1; | ||
262 | *buf |= (pd->msg->flags & I2C_M_RD) ? 1 : 0; | ||
263 | break; | ||
264 | default: | ||
265 | *buf = pd->msg->buf[pd->pos]; | ||
266 | } | ||
267 | } | ||
268 | |||
269 | static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd) | ||
270 | { | ||
271 | unsigned char data; | ||
272 | |||
273 | if (pd->pos == pd->msg->len) | ||
274 | return 1; | ||
275 | |||
276 | sh_mobile_i2c_get_data(pd, &data); | ||
277 | |||
278 | if (sh_mobile_i2c_is_last_byte(pd)) | ||
279 | i2c_op(pd, OP_TX_STOP, data); | ||
280 | else if (sh_mobile_i2c_is_first_byte(pd)) | ||
281 | i2c_op(pd, OP_TX_FIRST, data); | ||
282 | else | ||
283 | i2c_op(pd, OP_TX, data); | ||
284 | |||
285 | pd->pos++; | ||
286 | return 0; | ||
287 | } | ||
288 | |||
289 | static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd) | ||
290 | { | ||
291 | unsigned char data; | ||
292 | int real_pos; | ||
293 | |||
294 | do { | ||
295 | if (pd->pos <= -1) { | ||
296 | sh_mobile_i2c_get_data(pd, &data); | ||
297 | |||
298 | if (sh_mobile_i2c_is_first_byte(pd)) | ||
299 | i2c_op(pd, OP_TX_FIRST, data); | ||
300 | else | ||
301 | i2c_op(pd, OP_TX, data); | ||
302 | break; | ||
303 | } | ||
304 | |||
305 | if (pd->pos == 0) { | ||
306 | i2c_op(pd, OP_TX_TO_RX, 0); | ||
307 | break; | ||
308 | } | ||
309 | |||
310 | real_pos = pd->pos - 2; | ||
311 | |||
312 | if (pd->pos == pd->msg->len) { | ||
313 | if (real_pos < 0) { | ||
314 | i2c_op(pd, OP_RX_STOP, 0); | ||
315 | break; | ||
316 | } | ||
317 | data = i2c_op(pd, OP_RX_STOP_DATA, 0); | ||
318 | } else | ||
319 | data = i2c_op(pd, OP_RX, 0); | ||
320 | |||
321 | pd->msg->buf[real_pos] = data; | ||
322 | } while (0); | ||
323 | |||
324 | pd->pos++; | ||
325 | return pd->pos == (pd->msg->len + 2); | ||
326 | } | ||
327 | |||
160 | static irqreturn_t sh_mobile_i2c_isr(int irq, void *dev_id) | 328 | static irqreturn_t sh_mobile_i2c_isr(int irq, void *dev_id) |
161 | { | 329 | { |
162 | struct platform_device *dev = dev_id; | 330 | struct platform_device *dev = dev_id; |
163 | struct sh_mobile_i2c_data *pd = platform_get_drvdata(dev); | 331 | struct sh_mobile_i2c_data *pd = platform_get_drvdata(dev); |
164 | struct i2c_msg *msg = pd->msg; | 332 | unsigned char sr; |
165 | unsigned char data, sr; | 333 | int wakeup; |
166 | int wakeup = 0; | ||
167 | 334 | ||
168 | sr = ioread8(ICSR(pd)); | 335 | sr = ioread8(ICSR(pd)); |
169 | pd->sr |= sr; | 336 | pd->sr |= sr; /* remember state */ |
170 | 337 | ||
171 | dev_dbg(pd->dev, "i2c_isr 0x%02x 0x%02x %s %d %d!\n", sr, pd->sr, | 338 | dev_dbg(pd->dev, "i2c_isr 0x%02x 0x%02x %s %d %d!\n", sr, pd->sr, |
172 | (msg->flags & I2C_M_RD) ? "read" : "write", | 339 | (pd->msg->flags & I2C_M_RD) ? "read" : "write", |
173 | pd->pos, msg->len); | 340 | pd->pos, pd->msg->len); |
174 | 341 | ||
175 | if (sr & (ICSR_AL | ICSR_TACK)) { | 342 | if (sr & (ICSR_AL | ICSR_TACK)) { |
176 | iowrite8(0, ICIC(pd)); /* disable interrupts */ | 343 | /* don't interrupt transaction - continue to issue stop */ |
177 | wakeup = 1; | 344 | iowrite8(sr & ~(ICSR_AL | ICSR_TACK), ICSR(pd)); |
178 | goto do_wakeup; | 345 | wakeup = 0; |
179 | } | 346 | } else if (pd->msg->flags & I2C_M_RD) |
347 | wakeup = sh_mobile_i2c_isr_rx(pd); | ||
348 | else | ||
349 | wakeup = sh_mobile_i2c_isr_tx(pd); | ||
180 | 350 | ||
181 | if (pd->pos == msg->len) { | 351 | if (sr & ICSR_WAIT) /* TODO: add delay here to support slow acks */ |
182 | i2c_op(pd, OP_RX_ONLY, 0); | 352 | iowrite8(sr & ~ICSR_WAIT, ICSR(pd)); |
183 | wakeup = 1; | ||
184 | goto do_wakeup; | ||
185 | } | ||
186 | 353 | ||
187 | if (pd->pos == -1) { | ||
188 | data = (msg->addr & 0x7f) << 1; | ||
189 | data |= (msg->flags & I2C_M_RD) ? 1 : 0; | ||
190 | } else | ||
191 | data = msg->buf[pd->pos]; | ||
192 | |||
193 | if ((pd->pos == -1) || !(msg->flags & I2C_M_RD)) { | ||
194 | if (msg->flags & I2C_M_RD) | ||
195 | i2c_op(pd, OP_TX_TO_RX, data); | ||
196 | else if (pd->pos == (msg->len - 1)) { | ||
197 | i2c_op(pd, OP_TX_STOP, data); | ||
198 | wakeup = 1; | ||
199 | } else | ||
200 | i2c_op(pd, OP_TX_ONLY, data); | ||
201 | } else { | ||
202 | if (pd->pos == (msg->len - 1)) | ||
203 | data = i2c_op(pd, OP_RX_STOP, 0); | ||
204 | else | ||
205 | data = i2c_op(pd, OP_RX_ONLY, 0); | ||
206 | |||
207 | msg->buf[pd->pos] = data; | ||
208 | } | ||
209 | pd->pos++; | ||
210 | |||
211 | do_wakeup: | ||
212 | if (wakeup) { | 354 | if (wakeup) { |
213 | pd->sr |= SW_DONE; | 355 | pd->sr |= SW_DONE; |
214 | wake_up(&pd->wait); | 356 | wake_up(&pd->wait); |
@@ -219,6 +361,11 @@ static irqreturn_t sh_mobile_i2c_isr(int irq, void *dev_id) | |||
219 | 361 | ||
220 | static int start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg) | 362 | static int start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg) |
221 | { | 363 | { |
364 | if (usr_msg->len == 0 && (usr_msg->flags & I2C_M_RD)) { | ||
365 | dev_err(pd->dev, "Unsupported zero length i2c read\n"); | ||
366 | return -EIO; | ||
367 | } | ||
368 | |||
222 | /* Initialize channel registers */ | 369 | /* Initialize channel registers */ |
223 | iowrite8(ioread8(ICCR(pd)) & ~ICCR_ICE, ICCR(pd)); | 370 | iowrite8(ioread8(ICCR(pd)) & ~ICCR_ICE, ICCR(pd)); |
224 | 371 | ||
@@ -233,9 +380,8 @@ static int start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg) | |||
233 | pd->pos = -1; | 380 | pd->pos = -1; |
234 | pd->sr = 0; | 381 | pd->sr = 0; |
235 | 382 | ||
236 | /* Enable all interrupts except wait */ | 383 | /* Enable all interrupts to begin with */ |
237 | iowrite8(ioread8(ICIC(pd)) | ICIC_ALE | ICIC_TACKE | ICIC_DTEE, | 384 | iowrite8(ICIC_WAITE | ICIC_ALE | ICIC_TACKE | ICIC_DTEE, ICIC(pd)); |
238 | ICIC(pd)); | ||
239 | return 0; | 385 | return 0; |
240 | } | 386 | } |
241 | 387 | ||
@@ -268,25 +414,18 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter, | |||
268 | if (!k) | 414 | if (!k) |
269 | dev_err(pd->dev, "Transfer request timed out\n"); | 415 | dev_err(pd->dev, "Transfer request timed out\n"); |
270 | 416 | ||
271 | retry_count = 10; | 417 | retry_count = 1000; |
272 | again: | 418 | again: |
273 | val = ioread8(ICSR(pd)); | 419 | val = ioread8(ICSR(pd)); |
274 | 420 | ||
275 | dev_dbg(pd->dev, "val 0x%02x pd->sr 0x%02x\n", val, pd->sr); | 421 | dev_dbg(pd->dev, "val 0x%02x pd->sr 0x%02x\n", val, pd->sr); |
276 | 422 | ||
277 | if ((val | pd->sr) & (ICSR_TACK | ICSR_AL)) { | ||
278 | err = -EIO; | ||
279 | break; | ||
280 | } | ||
281 | |||
282 | /* the interrupt handler may wake us up before the | 423 | /* the interrupt handler may wake us up before the |
283 | * transfer is finished, so poll the hardware | 424 | * transfer is finished, so poll the hardware |
284 | * until we're done. | 425 | * until we're done. |
285 | */ | 426 | */ |
286 | 427 | if (val & ICSR_BUSY) { | |
287 | if (!(!(val & ICSR_BUSY) && (val & ICSR_SCLM) && | 428 | udelay(10); |
288 | (val & ICSR_SDAM))) { | ||
289 | msleep(1); | ||
290 | if (retry_count--) | 429 | if (retry_count--) |
291 | goto again; | 430 | goto again; |
292 | 431 | ||
@@ -294,6 +433,12 @@ again: | |||
294 | dev_err(pd->dev, "Polling timed out\n"); | 433 | dev_err(pd->dev, "Polling timed out\n"); |
295 | break; | 434 | break; |
296 | } | 435 | } |
436 | |||
437 | /* handle missing acknowledge and arbitration lost */ | ||
438 | if ((val | pd->sr) & (ICSR_TACK | ICSR_AL)) { | ||
439 | err = -EIO; | ||
440 | break; | ||
441 | } | ||
297 | } | 442 | } |
298 | 443 | ||
299 | deactivate_ch(pd); | 444 | deactivate_ch(pd); |
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index 862eb352a2d9..9f194d9efd91 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c | |||
@@ -36,6 +36,7 @@ | |||
36 | VT8237S 0x3372 yes | 36 | VT8237S 0x3372 yes |
37 | VT8251 0x3287 yes | 37 | VT8251 0x3287 yes |
38 | CX700 0x8324 yes | 38 | CX700 0x8324 yes |
39 | VX800/VX820 0x8353 yes | ||
39 | 40 | ||
40 | Note: we assume there can only be one device, with one SMBus interface. | 41 | Note: we assume there can only be one device, with one SMBus interface. |
41 | */ | 42 | */ |
@@ -82,6 +83,7 @@ static unsigned short SMBHSTCFG = 0xD2; | |||
82 | #define VT596_BYTE 0x04 | 83 | #define VT596_BYTE 0x04 |
83 | #define VT596_BYTE_DATA 0x08 | 84 | #define VT596_BYTE_DATA 0x08 |
84 | #define VT596_WORD_DATA 0x0C | 85 | #define VT596_WORD_DATA 0x0C |
86 | #define VT596_PROC_CALL 0x10 | ||
85 | #define VT596_BLOCK_DATA 0x14 | 87 | #define VT596_BLOCK_DATA 0x14 |
86 | #define VT596_I2C_BLOCK_DATA 0x34 | 88 | #define VT596_I2C_BLOCK_DATA 0x34 |
87 | 89 | ||
@@ -232,6 +234,12 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr, | |||
232 | } | 234 | } |
233 | size = VT596_WORD_DATA; | 235 | size = VT596_WORD_DATA; |
234 | break; | 236 | break; |
237 | case I2C_SMBUS_PROC_CALL: | ||
238 | outb_p(command, SMBHSTCMD); | ||
239 | outb_p(data->word & 0xff, SMBHSTDAT0); | ||
240 | outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1); | ||
241 | size = VT596_PROC_CALL; | ||
242 | break; | ||
235 | case I2C_SMBUS_I2C_BLOCK_DATA: | 243 | case I2C_SMBUS_I2C_BLOCK_DATA: |
236 | if (!(vt596_features & FEATURE_I2CBLOCK)) | 244 | if (!(vt596_features & FEATURE_I2CBLOCK)) |
237 | goto exit_unsupported; | 245 | goto exit_unsupported; |
@@ -262,6 +270,9 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr, | |||
262 | if (status) | 270 | if (status) |
263 | return status; | 271 | return status; |
264 | 272 | ||
273 | if (size == VT596_PROC_CALL) | ||
274 | read_write = I2C_SMBUS_READ; | ||
275 | |||
265 | if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK)) | 276 | if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK)) |
266 | return 0; | 277 | return 0; |
267 | 278 | ||
@@ -271,6 +282,7 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr, | |||
271 | data->byte = inb_p(SMBHSTDAT0); | 282 | data->byte = inb_p(SMBHSTDAT0); |
272 | break; | 283 | break; |
273 | case VT596_WORD_DATA: | 284 | case VT596_WORD_DATA: |
285 | case VT596_PROC_CALL: | ||
274 | data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8); | 286 | data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8); |
275 | break; | 287 | break; |
276 | case VT596_I2C_BLOCK_DATA: | 288 | case VT596_I2C_BLOCK_DATA: |
@@ -295,7 +307,7 @@ static u32 vt596_func(struct i2c_adapter *adapter) | |||
295 | { | 307 | { |
296 | u32 func = I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | | 308 | u32 func = I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | |
297 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | | 309 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | |
298 | I2C_FUNC_SMBUS_BLOCK_DATA; | 310 | I2C_SMBUS_PROC_CALL | I2C_FUNC_SMBUS_BLOCK_DATA; |
299 | 311 | ||
300 | if (vt596_features & FEATURE_I2CBLOCK) | 312 | if (vt596_features & FEATURE_I2CBLOCK) |
301 | func |= I2C_FUNC_SMBUS_I2C_BLOCK; | 313 | func |= I2C_FUNC_SMBUS_I2C_BLOCK; |
@@ -320,10 +332,6 @@ static int __devinit vt596_probe(struct pci_dev *pdev, | |||
320 | unsigned char temp; | 332 | unsigned char temp; |
321 | int error = -ENODEV; | 333 | int error = -ENODEV; |
322 | 334 | ||
323 | /* driver_data might come from user-space, so check it */ | ||
324 | if (id->driver_data & 1 || id->driver_data > 0xff) | ||
325 | return -EINVAL; | ||
326 | |||
327 | /* Determine the address of the SMBus areas */ | 335 | /* Determine the address of the SMBus areas */ |
328 | if (force_addr) { | 336 | if (force_addr) { |
329 | vt596_smba = force_addr & 0xfff0; | 337 | vt596_smba = force_addr & 0xfff0; |
@@ -396,6 +404,7 @@ found: | |||
396 | 404 | ||
397 | switch (pdev->device) { | 405 | switch (pdev->device) { |
398 | case PCI_DEVICE_ID_VIA_CX700: | 406 | case PCI_DEVICE_ID_VIA_CX700: |
407 | case PCI_DEVICE_ID_VIA_VX800: | ||
399 | case PCI_DEVICE_ID_VIA_8251: | 408 | case PCI_DEVICE_ID_VIA_8251: |
400 | case PCI_DEVICE_ID_VIA_8237: | 409 | case PCI_DEVICE_ID_VIA_8237: |
401 | case PCI_DEVICE_ID_VIA_8237A: | 410 | case PCI_DEVICE_ID_VIA_8237A: |
@@ -459,6 +468,8 @@ static struct pci_device_id vt596_ids[] = { | |||
459 | .driver_data = SMBBA3 }, | 468 | .driver_data = SMBBA3 }, |
460 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CX700), | 469 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CX700), |
461 | .driver_data = SMBBA3 }, | 470 | .driver_data = SMBBA3 }, |
471 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX800), | ||
472 | .driver_data = SMBBA3 }, | ||
462 | { 0, } | 473 | { 0, } |
463 | }; | 474 | }; |
464 | 475 | ||
@@ -468,7 +479,6 @@ static struct pci_driver vt596_driver = { | |||
468 | .name = "vt596_smbus", | 479 | .name = "vt596_smbus", |
469 | .id_table = vt596_ids, | 480 | .id_table = vt596_ids, |
470 | .probe = vt596_probe, | 481 | .probe = vt596_probe, |
471 | .dynids.use_driver_data = 1, | ||
472 | }; | 482 | }; |
473 | 483 | ||
474 | static int __init i2c_vt596_init(void) | 484 | static int __init i2c_vt596_init(void) |