diff options
68 files changed, 1730 insertions, 1590 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index 46f2a559b27c..031029e89fd9 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt | |||
@@ -216,17 +216,6 @@ Who: Thomas Gleixner <tglx@linutronix.de> | |||
216 | 216 | ||
217 | --------------------------- | 217 | --------------------------- |
218 | 218 | ||
219 | What: i2c-ite and i2c-algo-ite drivers | ||
220 | When: September 2006 | ||
221 | Why: These drivers never compiled since they were added to the kernel | ||
222 | tree 5 years ago. This feature removal can be reevaluated if | ||
223 | someone shows interest in the drivers, fixes them and takes over | ||
224 | maintenance. | ||
225 | http://marc.theaimsgroup.com/?l=linux-mips&m=115040510817448 | ||
226 | Who: Jean Delvare <khali@linux-fr.org> | ||
227 | |||
228 | --------------------------- | ||
229 | |||
230 | What: Bridge netfilter deferred IPv4/IPv6 output hook calling | 219 | What: Bridge netfilter deferred IPv4/IPv6 output hook calling |
231 | When: January 2007 | 220 | When: January 2007 |
232 | Why: The deferred output hooks are a layering violation causing unusual | 221 | Why: The deferred output hooks are a layering violation causing unusual |
diff --git a/Documentation/i2c/busses/i2c-amd8111 b/Documentation/i2c/busses/i2c-amd8111 index db294ee7455a..460dd6635fd2 100644 --- a/Documentation/i2c/busses/i2c-amd8111 +++ b/Documentation/i2c/busses/i2c-amd8111 | |||
@@ -5,7 +5,7 @@ Supported adapters: | |||
5 | 5 | ||
6 | Datasheets: | 6 | Datasheets: |
7 | AMD datasheet not yet available, but almost everything can be found | 7 | AMD datasheet not yet available, but almost everything can be found |
8 | in publically available ACPI 2.0 specification, which the adapter | 8 | in the publicly available ACPI 2.0 specification, which the adapter |
9 | follows. | 9 | follows. |
10 | 10 | ||
11 | Author: Vojtech Pavlik <vojtech@suse.cz> | 11 | Author: Vojtech Pavlik <vojtech@suse.cz> |
diff --git a/Documentation/i2c/busses/i2c-i801 b/Documentation/i2c/busses/i2c-i801 index e46c23458242..3db69a086c41 100644 --- a/Documentation/i2c/busses/i2c-i801 +++ b/Documentation/i2c/busses/i2c-i801 | |||
@@ -9,7 +9,10 @@ Supported adapters: | |||
9 | * Intel 82801EB/ER (ICH5) (HW PEC supported, 32 byte buffer not supported) | 9 | * Intel 82801EB/ER (ICH5) (HW PEC supported, 32 byte buffer not supported) |
10 | * Intel 6300ESB | 10 | * Intel 6300ESB |
11 | * Intel 82801FB/FR/FW/FRW (ICH6) | 11 | * Intel 82801FB/FR/FW/FRW (ICH6) |
12 | * Intel ICH7 | 12 | * Intel 82801G (ICH7) |
13 | * Intel 631xESB/632xESB (ESB2) | ||
14 | * Intel 82801H (ICH8) | ||
15 | * Intel ICH9 | ||
13 | Datasheets: Publicly available at the Intel website | 16 | Datasheets: Publicly available at the Intel website |
14 | 17 | ||
15 | Authors: | 18 | Authors: |
diff --git a/Documentation/i2c/busses/i2c-nforce2 b/Documentation/i2c/busses/i2c-nforce2 index cd49c428a3ab..7f61fbc03f7f 100644 --- a/Documentation/i2c/busses/i2c-nforce2 +++ b/Documentation/i2c/busses/i2c-nforce2 | |||
@@ -10,11 +10,11 @@ Supported adapters: | |||
10 | * nForce4 MCP51 10de:0264 | 10 | * nForce4 MCP51 10de:0264 |
11 | * nForce4 MCP55 10de:0368 | 11 | * nForce4 MCP55 10de:0368 |
12 | 12 | ||
13 | Datasheet: not publically available, but seems to be similar to the | 13 | Datasheet: not publicly available, but seems to be similar to the |
14 | AMD-8111 SMBus 2.0 adapter. | 14 | AMD-8111 SMBus 2.0 adapter. |
15 | 15 | ||
16 | Authors: | 16 | Authors: |
17 | Hans-Frieder Vogt <hfvogt@arcor.de>, | 17 | Hans-Frieder Vogt <hfvogt@gmx.net>, |
18 | Thomas Leibold <thomas@plx.com>, | 18 | Thomas Leibold <thomas@plx.com>, |
19 | Patrick Dreker <patrick@dreker.de> | 19 | Patrick Dreker <patrick@dreker.de> |
20 | 20 | ||
@@ -38,7 +38,7 @@ Notes | |||
38 | ----- | 38 | ----- |
39 | 39 | ||
40 | The SMBus adapter in the nForce2 chipset seems to be very similar to the | 40 | The SMBus adapter in the nForce2 chipset seems to be very similar to the |
41 | SMBus 2.0 adapter in the AMD-8111 southbridge. However, I could only get | 41 | SMBus 2.0 adapter in the AMD-8111 south bridge. However, I could only get |
42 | the driver to work with direct I/O access, which is different to the EC | 42 | the driver to work with direct I/O access, which is different to the EC |
43 | interface of the AMD-8111. Tested on Asus A7N8X. The ACPI DSDT table of the | 43 | interface of the AMD-8111. Tested on Asus A7N8X. The ACPI DSDT table of the |
44 | Asus A7N8X lists two SMBuses, both of which are supported by this driver. | 44 | Asus A7N8X lists two SMBuses, both of which are supported by this driver. |
diff --git a/arch/arm/mach-pnx4008/Makefile b/arch/arm/mach-pnx4008/Makefile index b457ca0a431a..777564c90a12 100644 --- a/arch/arm/mach-pnx4008/Makefile +++ b/arch/arm/mach-pnx4008/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for the linux kernel. | 2 | # Makefile for the linux kernel. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := core.o irq.o time.o clock.o gpio.o serial.o dma.o | 5 | obj-y := core.o irq.o time.o clock.o gpio.o serial.o dma.o i2c.o |
6 | obj-m := | 6 | obj-m := |
7 | obj-n := | 7 | obj-n := |
8 | obj- := | 8 | obj- := |
diff --git a/arch/arm/mach-pnx4008/i2c.c b/arch/arm/mach-pnx4008/i2c.c new file mode 100644 index 000000000000..6f308827c4fe --- /dev/null +++ b/arch/arm/mach-pnx4008/i2c.c | |||
@@ -0,0 +1,167 @@ | |||
1 | /* | ||
2 | * I2C initialization for PNX4008. | ||
3 | * | ||
4 | * Author: Vitaly Wool <vitalywool@gmail.com> | ||
5 | * | ||
6 | * 2005-2006 (c) MontaVista Software, Inc. This file is licensed under | ||
7 | * the terms of the GNU General Public License version 2. This program | ||
8 | * is licensed "as is" without any warranty of any kind, whether express | ||
9 | * or implied. | ||
10 | */ | ||
11 | |||
12 | #include <linux/clk.h> | ||
13 | #include <linux/i2c.h> | ||
14 | #include <linux/i2c-pnx.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/err.h> | ||
17 | #include <asm/arch/platform.h> | ||
18 | #include <asm/arch/i2c.h> | ||
19 | |||
20 | static int set_clock_run(struct platform_device *pdev) | ||
21 | { | ||
22 | struct clk *clk; | ||
23 | char name[10]; | ||
24 | int retval = 0; | ||
25 | |||
26 | snprintf(name, 10, "i2c%d_ck", pdev->id); | ||
27 | clk = clk_get(&pdev->dev, name); | ||
28 | if (!IS_ERR(clk)) { | ||
29 | clk_set_rate(clk, 1); | ||
30 | clk_put(clk); | ||
31 | } else | ||
32 | retval = -ENOENT; | ||
33 | |||
34 | return retval; | ||
35 | } | ||
36 | |||
37 | static int set_clock_stop(struct platform_device *pdev) | ||
38 | { | ||
39 | struct clk *clk; | ||
40 | char name[10]; | ||
41 | int retval = 0; | ||
42 | |||
43 | snprintf(name, 10, "i2c%d_ck", pdev->id); | ||
44 | clk = clk_get(&pdev->dev, name); | ||
45 | if (!IS_ERR(clk)) { | ||
46 | clk_set_rate(clk, 0); | ||
47 | clk_put(clk); | ||
48 | } else | ||
49 | retval = -ENOENT; | ||
50 | |||
51 | return retval; | ||
52 | } | ||
53 | |||
54 | static int i2c_pnx_suspend(struct platform_device *pdev, pm_message_t state) | ||
55 | { | ||
56 | int retval = 0; | ||
57 | #ifdef CONFIG_PM | ||
58 | retval = set_clock_run(pdev); | ||
59 | #endif | ||
60 | return retval; | ||
61 | } | ||
62 | |||
63 | static int i2c_pnx_resume(struct platform_device *pdev) | ||
64 | { | ||
65 | int retval = 0; | ||
66 | #ifdef CONFIG_PM | ||
67 | retval = set_clock_run(pdev); | ||
68 | #endif | ||
69 | return retval; | ||
70 | } | ||
71 | |||
72 | static u32 calculate_input_freq(struct platform_device *pdev) | ||
73 | { | ||
74 | return HCLK_MHZ; | ||
75 | } | ||
76 | |||
77 | |||
78 | static struct i2c_pnx_algo_data pnx_algo_data0 = { | ||
79 | .base = PNX4008_I2C1_BASE, | ||
80 | .irq = I2C_1_INT, | ||
81 | }; | ||
82 | |||
83 | static struct i2c_pnx_algo_data pnx_algo_data1 = { | ||
84 | .base = PNX4008_I2C2_BASE, | ||
85 | .irq = I2C_2_INT, | ||
86 | }; | ||
87 | |||
88 | static struct i2c_pnx_algo_data pnx_algo_data2 = { | ||
89 | .base = (PNX4008_USB_CONFIG_BASE + 0x300), | ||
90 | .irq = USB_I2C_INT, | ||
91 | }; | ||
92 | |||
93 | static struct i2c_adapter pnx_adapter0 = { | ||
94 | .name = I2C_CHIP_NAME "0", | ||
95 | .algo_data = &pnx_algo_data0, | ||
96 | }; | ||
97 | static struct i2c_adapter pnx_adapter1 = { | ||
98 | .name = I2C_CHIP_NAME "1", | ||
99 | .algo_data = &pnx_algo_data1, | ||
100 | }; | ||
101 | |||
102 | static struct i2c_adapter pnx_adapter2 = { | ||
103 | .name = "USB-I2C", | ||
104 | .algo_data = &pnx_algo_data2, | ||
105 | }; | ||
106 | |||
107 | static struct i2c_pnx_data i2c0_data = { | ||
108 | .suspend = i2c_pnx_suspend, | ||
109 | .resume = i2c_pnx_resume, | ||
110 | .calculate_input_freq = calculate_input_freq, | ||
111 | .set_clock_run = set_clock_run, | ||
112 | .set_clock_stop = set_clock_stop, | ||
113 | .adapter = &pnx_adapter0, | ||
114 | }; | ||
115 | |||
116 | static struct i2c_pnx_data i2c1_data = { | ||
117 | .suspend = i2c_pnx_suspend, | ||
118 | .resume = i2c_pnx_resume, | ||
119 | .calculate_input_freq = calculate_input_freq, | ||
120 | .set_clock_run = set_clock_run, | ||
121 | .set_clock_stop = set_clock_stop, | ||
122 | .adapter = &pnx_adapter1, | ||
123 | }; | ||
124 | |||
125 | static struct i2c_pnx_data i2c2_data = { | ||
126 | .suspend = i2c_pnx_suspend, | ||
127 | .resume = i2c_pnx_resume, | ||
128 | .calculate_input_freq = calculate_input_freq, | ||
129 | .set_clock_run = set_clock_run, | ||
130 | .set_clock_stop = set_clock_stop, | ||
131 | .adapter = &pnx_adapter2, | ||
132 | }; | ||
133 | |||
134 | static struct platform_device i2c0_device = { | ||
135 | .name = "pnx-i2c", | ||
136 | .id = 0, | ||
137 | .dev = { | ||
138 | .platform_data = &i2c0_data, | ||
139 | }, | ||
140 | }; | ||
141 | |||
142 | static struct platform_device i2c1_device = { | ||
143 | .name = "pnx-i2c", | ||
144 | .id = 1, | ||
145 | .dev = { | ||
146 | .platform_data = &i2c1_data, | ||
147 | }, | ||
148 | }; | ||
149 | |||
150 | static struct platform_device i2c2_device = { | ||
151 | .name = "pnx-i2c", | ||
152 | .id = 2, | ||
153 | .dev = { | ||
154 | .platform_data = &i2c2_data, | ||
155 | }, | ||
156 | }; | ||
157 | |||
158 | static struct platform_device *devices[] __initdata = { | ||
159 | &i2c0_device, | ||
160 | &i2c1_device, | ||
161 | &i2c2_device, | ||
162 | }; | ||
163 | |||
164 | void __init pnx4008_register_i2c_devices(void) | ||
165 | { | ||
166 | platform_add_devices(devices, ARRAY_SIZE(devices)); | ||
167 | } | ||
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c index 68c67053f479..84d3fe76e94e 100644 --- a/arch/arm/mach-realview/core.c +++ b/arch/arm/mach-realview/core.c | |||
@@ -141,6 +141,19 @@ struct platform_device realview_smc91x_device = { | |||
141 | .resource = realview_smc91x_resources, | 141 | .resource = realview_smc91x_resources, |
142 | }; | 142 | }; |
143 | 143 | ||
144 | static struct resource realview_i2c_resource = { | ||
145 | .start = REALVIEW_I2C_BASE, | ||
146 | .end = REALVIEW_I2C_BASE + SZ_4K - 1, | ||
147 | .flags = IORESOURCE_MEM, | ||
148 | }; | ||
149 | |||
150 | struct platform_device realview_i2c_device = { | ||
151 | .name = "versatile-i2c", | ||
152 | .id = -1, | ||
153 | .num_resources = 1, | ||
154 | .resource = &realview_i2c_resource, | ||
155 | }; | ||
156 | |||
144 | #define REALVIEW_SYSMCI (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_MCI_OFFSET) | 157 | #define REALVIEW_SYSMCI (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_MCI_OFFSET) |
145 | 158 | ||
146 | static unsigned int realview_mmc_status(struct device *dev) | 159 | static unsigned int realview_mmc_status(struct device *dev) |
diff --git a/arch/arm/mach-realview/core.h b/arch/arm/mach-realview/core.h index 93e86d9f439c..2b53420f9c1b 100644 --- a/arch/arm/mach-realview/core.h +++ b/arch/arm/mach-realview/core.h | |||
@@ -108,6 +108,7 @@ static struct amba_device name##_device = { \ | |||
108 | 108 | ||
109 | extern struct platform_device realview_flash_device; | 109 | extern struct platform_device realview_flash_device; |
110 | extern struct platform_device realview_smc91x_device; | 110 | extern struct platform_device realview_smc91x_device; |
111 | extern struct platform_device realview_i2c_device; | ||
111 | extern struct mmc_platform_data realview_mmc0_plat_data; | 112 | extern struct mmc_platform_data realview_mmc0_plat_data; |
112 | extern struct mmc_platform_data realview_mmc1_plat_data; | 113 | extern struct mmc_platform_data realview_mmc1_plat_data; |
113 | extern struct clk realview_clcd_clk; | 114 | extern struct clk realview_clcd_clk; |
diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c index 84a959530fb6..9741b4d3c9cf 100644 --- a/arch/arm/mach-realview/realview_eb.c +++ b/arch/arm/mach-realview/realview_eb.c | |||
@@ -155,6 +155,7 @@ static void __init realview_eb_init(void) | |||
155 | 155 | ||
156 | platform_device_register(&realview_flash_device); | 156 | platform_device_register(&realview_flash_device); |
157 | platform_device_register(&realview_smc91x_device); | 157 | platform_device_register(&realview_smc91x_device); |
158 | platform_device_register(&realview_i2c_device); | ||
158 | 159 | ||
159 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { | 160 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { |
160 | struct amba_device *d = amba_devs[i]; | 161 | struct amba_device *d = amba_devs[i]; |
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c index 57196947559f..bf71507c76fd 100644 --- a/arch/arm/mach-versatile/core.c +++ b/arch/arm/mach-versatile/core.c | |||
@@ -325,6 +325,19 @@ static struct platform_device smc91x_device = { | |||
325 | .resource = smc91x_resources, | 325 | .resource = smc91x_resources, |
326 | }; | 326 | }; |
327 | 327 | ||
328 | static struct resource versatile_i2c_resource = { | ||
329 | .start = VERSATILE_I2C_BASE, | ||
330 | .end = VERSATILE_I2C_BASE + SZ_4K - 1, | ||
331 | .flags = IORESOURCE_MEM, | ||
332 | }; | ||
333 | |||
334 | static struct platform_device versatile_i2c_device = { | ||
335 | .name = "versatile-i2c", | ||
336 | .id = -1, | ||
337 | .num_resources = 1, | ||
338 | .resource = &versatile_i2c_resource, | ||
339 | }; | ||
340 | |||
328 | #define VERSATILE_SYSMCI (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET) | 341 | #define VERSATILE_SYSMCI (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET) |
329 | 342 | ||
330 | unsigned int mmc_status(struct device *dev) | 343 | unsigned int mmc_status(struct device *dev) |
@@ -775,6 +788,7 @@ void __init versatile_init(void) | |||
775 | clk_register(&versatile_clcd_clk); | 788 | clk_register(&versatile_clcd_clk); |
776 | 789 | ||
777 | platform_device_register(&versatile_flash_device); | 790 | platform_device_register(&versatile_flash_device); |
791 | platform_device_register(&versatile_i2c_device); | ||
778 | platform_device_register(&smc91x_device); | 792 | platform_device_register(&smc91x_device); |
779 | 793 | ||
780 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { | 794 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { |
diff --git a/drivers/acorn/char/i2c.c b/drivers/acorn/char/i2c.c index bdb9c8b78ed8..9e584a7af434 100644 --- a/drivers/acorn/char/i2c.c +++ b/drivers/acorn/char/i2c.c | |||
@@ -360,7 +360,7 @@ static int __init i2c_ioc_init(void) | |||
360 | if (ret >= 0){ | 360 | if (ret >= 0){ |
361 | ret = misc_register(&rtc_dev); | 361 | ret = misc_register(&rtc_dev); |
362 | if(ret < 0) | 362 | if(ret < 0) |
363 | i2c_bit_del_bus(&ioc_ops); | 363 | i2c_del_adapter(&ioc_ops); |
364 | } | 364 | } |
365 | 365 | ||
366 | return ret; | 366 | return ret; |
diff --git a/drivers/i2c/algos/Kconfig b/drivers/i2c/algos/Kconfig index c034820615bb..af0203409dd1 100644 --- a/drivers/i2c/algos/Kconfig +++ b/drivers/i2c/algos/Kconfig | |||
@@ -38,17 +38,6 @@ config I2C_ALGOPCA | |||
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-algo-pca. | 39 | will be called i2c-algo-pca. |
40 | 40 | ||
41 | config I2C_ALGOITE | ||
42 | tristate "ITE I2C Algorithm" | ||
43 | depends on MIPS_ITE8172 && I2C | ||
44 | help | ||
45 | This supports the use of the ITE8172 I2C interface found on some MIPS | ||
46 | systems. Say Y if you have one of these. You should also say Y for | ||
47 | the ITE I2C peripheral driver support below. | ||
48 | |||
49 | This support is also available as a module. If so, the module | ||
50 | will be called i2c-algo-ite. | ||
51 | |||
52 | config I2C_ALGO8XX | 41 | config I2C_ALGO8XX |
53 | tristate "MPC8xx CPM I2C interface" | 42 | tristate "MPC8xx CPM I2C interface" |
54 | depends on 8xx && I2C | 43 | depends on 8xx && I2C |
diff --git a/drivers/i2c/algos/Makefile b/drivers/i2c/algos/Makefile index 208be04a3dbd..cac1051bd4f1 100644 --- a/drivers/i2c/algos/Makefile +++ b/drivers/i2c/algos/Makefile | |||
@@ -5,7 +5,6 @@ | |||
5 | obj-$(CONFIG_I2C_ALGOBIT) += i2c-algo-bit.o | 5 | obj-$(CONFIG_I2C_ALGOBIT) += i2c-algo-bit.o |
6 | obj-$(CONFIG_I2C_ALGOPCF) += i2c-algo-pcf.o | 6 | obj-$(CONFIG_I2C_ALGOPCF) += i2c-algo-pcf.o |
7 | obj-$(CONFIG_I2C_ALGOPCA) += i2c-algo-pca.o | 7 | obj-$(CONFIG_I2C_ALGOPCA) += i2c-algo-pca.o |
8 | obj-$(CONFIG_I2C_ALGOITE) += i2c-algo-ite.o | ||
9 | obj-$(CONFIG_I2C_ALGO_SGI) += i2c-algo-sgi.o | 8 | obj-$(CONFIG_I2C_ALGO_SGI) += i2c-algo-sgi.o |
10 | 9 | ||
11 | ifeq ($(CONFIG_I2C_DEBUG_ALGO),y) | 10 | ifeq ($(CONFIG_I2C_DEBUG_ALGO),y) |
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index 21c36bfb5e6b..95aa5395a5be 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c | |||
@@ -540,15 +540,7 @@ int i2c_bit_add_bus(struct i2c_adapter *adap) | |||
540 | 540 | ||
541 | return i2c_add_adapter(adap); | 541 | return i2c_add_adapter(adap); |
542 | } | 542 | } |
543 | |||
544 | |||
545 | int i2c_bit_del_bus(struct i2c_adapter *adap) | ||
546 | { | ||
547 | return i2c_del_adapter(adap); | ||
548 | } | ||
549 | |||
550 | EXPORT_SYMBOL(i2c_bit_add_bus); | 543 | EXPORT_SYMBOL(i2c_bit_add_bus); |
551 | EXPORT_SYMBOL(i2c_bit_del_bus); | ||
552 | 544 | ||
553 | MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); | 545 | MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); |
554 | MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm"); | 546 | MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm"); |
diff --git a/drivers/i2c/algos/i2c-algo-ite.c b/drivers/i2c/algos/i2c-algo-ite.c deleted file mode 100644 index 70d8eefb5efc..000000000000 --- a/drivers/i2c/algos/i2c-algo-ite.c +++ /dev/null | |||
@@ -1,806 +0,0 @@ | |||
1 | /* | ||
2 | ------------------------------------------------------------------------- | ||
3 | i2c-algo-ite.c i2c driver algorithms for ITE adapters | ||
4 | |||
5 | Hai-Pao Fan, MontaVista Software, Inc. | ||
6 | hpfan@mvista.com or source@mvista.com | ||
7 | |||
8 | Copyright 2000 MontaVista Software Inc. | ||
9 | |||
10 | --------------------------------------------------------------------------- | ||
11 | This file was highly leveraged from i2c-algo-pcf.c, which was created | ||
12 | by Simon G. Vogl and Hans Berglund: | ||
13 | |||
14 | |||
15 | Copyright (C) 1995-1997 Simon G. Vogl | ||
16 | 1998-2000 Hans Berglund | ||
17 | |||
18 | This program is free software; you can redistribute it and/or modify | ||
19 | it under the terms of the GNU General Public License as published by | ||
20 | the Free Software Foundation; either version 2 of the License, or | ||
21 | (at your option) any later version. | ||
22 | |||
23 | This program is distributed in the hope that it will be useful, | ||
24 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
25 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
26 | GNU General Public License for more details. | ||
27 | |||
28 | You should have received a copy of the GNU General Public License | ||
29 | along with this program; if not, write to the Free Software | ||
30 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
31 | /* ------------------------------------------------------------------------- */ | ||
32 | |||
33 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and | ||
34 | Frodo Looijaard <frodol@dds.nl> ,and also from Martin Bailey | ||
35 | <mbailey@littlefeet-inc.com> */ | ||
36 | |||
37 | #include <linux/kernel.h> | ||
38 | #include <linux/module.h> | ||
39 | #include <linux/delay.h> | ||
40 | #include <linux/slab.h> | ||
41 | #include <linux/init.h> | ||
42 | #include <asm/uaccess.h> | ||
43 | #include <linux/ioport.h> | ||
44 | #include <linux/errno.h> | ||
45 | #include <linux/sched.h> | ||
46 | |||
47 | #include <linux/i2c.h> | ||
48 | #include <linux/i2c-algo-ite.h> | ||
49 | #include "i2c-algo-ite.h" | ||
50 | |||
51 | #define PM_DSR IT8172_PCI_IO_BASE + IT_PM_DSR | ||
52 | #define PM_IBSR IT8172_PCI_IO_BASE + IT_PM_DSR + 0x04 | ||
53 | #define GPIO_CCR IT8172_PCI_IO_BASE + IT_GPCCR | ||
54 | |||
55 | #define DEB2(x) if (i2c_debug>=2) x | ||
56 | #define DEB3(x) if (i2c_debug>=3) x /* print several statistical values*/ | ||
57 | #define DEF_TIMEOUT 16 | ||
58 | |||
59 | |||
60 | /* module parameters: | ||
61 | */ | ||
62 | static int i2c_debug; | ||
63 | static int iic_test; /* see if the line-setting functions work */ | ||
64 | |||
65 | /* --- setting states on the bus with the right timing: --------------- */ | ||
66 | |||
67 | #define get_clock(adap) adap->getclock(adap->data) | ||
68 | #define iic_outw(adap, reg, val) adap->setiic(adap->data, reg, val) | ||
69 | #define iic_inw(adap, reg) adap->getiic(adap->data, reg) | ||
70 | |||
71 | |||
72 | /* --- other auxiliary functions -------------------------------------- */ | ||
73 | |||
74 | static void iic_start(struct i2c_algo_iic_data *adap) | ||
75 | { | ||
76 | iic_outw(adap,ITE_I2CHCR,ITE_CMD); | ||
77 | } | ||
78 | |||
79 | static void iic_stop(struct i2c_algo_iic_data *adap) | ||
80 | { | ||
81 | iic_outw(adap,ITE_I2CHCR,0); | ||
82 | iic_outw(adap,ITE_I2CHSR,ITE_I2CHSR_TDI); | ||
83 | } | ||
84 | |||
85 | static void iic_reset(struct i2c_algo_iic_data *adap) | ||
86 | { | ||
87 | iic_outw(adap, PM_IBSR, iic_inw(adap, PM_IBSR) | 0x80); | ||
88 | } | ||
89 | |||
90 | |||
91 | static int wait_for_bb(struct i2c_algo_iic_data *adap) | ||
92 | { | ||
93 | int timeout = DEF_TIMEOUT; | ||
94 | short status; | ||
95 | |||
96 | status = iic_inw(adap, ITE_I2CHSR); | ||
97 | #ifndef STUB_I2C | ||
98 | while (timeout-- && (status & ITE_I2CHSR_HB)) { | ||
99 | udelay(1000); /* How much is this? */ | ||
100 | status = iic_inw(adap, ITE_I2CHSR); | ||
101 | } | ||
102 | #endif | ||
103 | if (timeout<=0) { | ||
104 | printk(KERN_ERR "Timeout, host is busy\n"); | ||
105 | iic_reset(adap); | ||
106 | } | ||
107 | return(timeout<=0); | ||
108 | } | ||
109 | |||
110 | /* After we issue a transaction on the IIC bus, this function | ||
111 | * is called. It puts this process to sleep until we get an interrupt from | ||
112 | * from the controller telling us that the transaction we requested in complete. | ||
113 | */ | ||
114 | static int wait_for_pin(struct i2c_algo_iic_data *adap, short *status) { | ||
115 | |||
116 | int timeout = DEF_TIMEOUT; | ||
117 | |||
118 | timeout = wait_for_bb(adap); | ||
119 | if (timeout) { | ||
120 | DEB2(printk("Timeout waiting for host not busy\n");) | ||
121 | return -EIO; | ||
122 | } | ||
123 | timeout = DEF_TIMEOUT; | ||
124 | |||
125 | *status = iic_inw(adap, ITE_I2CHSR); | ||
126 | #ifndef STUB_I2C | ||
127 | while (timeout-- && !(*status & ITE_I2CHSR_TDI)) { | ||
128 | adap->waitforpin(); | ||
129 | *status = iic_inw(adap, ITE_I2CHSR); | ||
130 | } | ||
131 | #endif | ||
132 | if (timeout <= 0) | ||
133 | return(-1); | ||
134 | else | ||
135 | return(0); | ||
136 | } | ||
137 | |||
138 | static int wait_for_fe(struct i2c_algo_iic_data *adap, short *status) | ||
139 | { | ||
140 | int timeout = DEF_TIMEOUT; | ||
141 | |||
142 | *status = iic_inw(adap, ITE_I2CFSR); | ||
143 | #ifndef STUB_I2C | ||
144 | while (timeout-- && (*status & ITE_I2CFSR_FE)) { | ||
145 | udelay(1000); | ||
146 | iic_inw(adap, ITE_I2CFSR); | ||
147 | } | ||
148 | #endif | ||
149 | if (timeout <= 0) | ||
150 | return(-1); | ||
151 | else | ||
152 | return(0); | ||
153 | } | ||
154 | |||
155 | static int iic_init (struct i2c_algo_iic_data *adap) | ||
156 | { | ||
157 | short i; | ||
158 | |||
159 | /* Clear bit 7 to set I2C to normal operation mode */ | ||
160 | i=iic_inw(adap, PM_DSR)& 0xff7f; | ||
161 | iic_outw(adap, PM_DSR, i); | ||
162 | |||
163 | /* set IT_GPCCR port C bit 2&3 as function 2 */ | ||
164 | i = iic_inw(adap, GPIO_CCR) & 0xfc0f; | ||
165 | iic_outw(adap,GPIO_CCR,i); | ||
166 | |||
167 | /* Clear slave address/sub-address */ | ||
168 | iic_outw(adap,ITE_I2CSAR, 0); | ||
169 | iic_outw(adap,ITE_I2CSSAR, 0); | ||
170 | |||
171 | /* Set clock counter register */ | ||
172 | iic_outw(adap,ITE_I2CCKCNT, get_clock(adap)); | ||
173 | |||
174 | /* Set START/reSTART/STOP time registers */ | ||
175 | iic_outw(adap,ITE_I2CSHDR, 0x0a); | ||
176 | iic_outw(adap,ITE_I2CRSUR, 0x0a); | ||
177 | iic_outw(adap,ITE_I2CPSUR, 0x0a); | ||
178 | |||
179 | /* Enable interrupts on completing the current transaction */ | ||
180 | iic_outw(adap,ITE_I2CHCR, ITE_I2CHCR_IE | ITE_I2CHCR_HCE); | ||
181 | |||
182 | /* Clear transfer count */ | ||
183 | iic_outw(adap,ITE_I2CFBCR, 0x0); | ||
184 | |||
185 | DEB2(printk("iic_init: Initialized IIC on ITE 0x%x\n", | ||
186 | iic_inw(adap, ITE_I2CHSR))); | ||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | |||
191 | /* | ||
192 | * Sanity check for the adapter hardware - check the reaction of | ||
193 | * the bus lines only if it seems to be idle. | ||
194 | */ | ||
195 | static int test_bus(struct i2c_algo_iic_data *adap, char *name) { | ||
196 | #if 0 | ||
197 | int scl,sda; | ||
198 | sda=getsda(adap); | ||
199 | if (adap->getscl==NULL) { | ||
200 | printk("test_bus: Warning: Adapter can't read from clock line - skipping test.\n"); | ||
201 | return 0; | ||
202 | } | ||
203 | scl=getscl(adap); | ||
204 | printk("test_bus: Adapter: %s scl: %d sda: %d -- testing...\n", | ||
205 | name,getscl(adap),getsda(adap)); | ||
206 | if (!scl || !sda ) { | ||
207 | printk("test_bus: %s seems to be busy.\n",adap->name); | ||
208 | goto bailout; | ||
209 | } | ||
210 | sdalo(adap); | ||
211 | printk("test_bus:1 scl: %d sda: %d\n", getscl(adap), | ||
212 | getsda(adap)); | ||
213 | if ( 0 != getsda(adap) ) { | ||
214 | printk("test_bus: %s SDA stuck high!\n",name); | ||
215 | sdahi(adap); | ||
216 | goto bailout; | ||
217 | } | ||
218 | if ( 0 == getscl(adap) ) { | ||
219 | printk("test_bus: %s SCL unexpected low while pulling SDA low!\n", | ||
220 | name); | ||
221 | goto bailout; | ||
222 | } | ||
223 | sdahi(adap); | ||
224 | printk("test_bus:2 scl: %d sda: %d\n", getscl(adap), | ||
225 | getsda(adap)); | ||
226 | if ( 0 == getsda(adap) ) { | ||
227 | printk("test_bus: %s SDA stuck low!\n",name); | ||
228 | sdahi(adap); | ||
229 | goto bailout; | ||
230 | } | ||
231 | if ( 0 == getscl(adap) ) { | ||
232 | printk("test_bus: %s SCL unexpected low while SDA high!\n", | ||
233 | adap->name); | ||
234 | goto bailout; | ||
235 | } | ||
236 | scllo(adap); | ||
237 | printk("test_bus:3 scl: %d sda: %d\n", getscl(adap), | ||
238 | getsda(adap)); | ||
239 | if ( 0 != getscl(adap) ) { | ||
240 | |||
241 | sclhi(adap); | ||
242 | goto bailout; | ||
243 | } | ||
244 | if ( 0 == getsda(adap) ) { | ||
245 | printk("test_bus: %s SDA unexpected low while pulling SCL low!\n", | ||
246 | name); | ||
247 | goto bailout; | ||
248 | } | ||
249 | sclhi(adap); | ||
250 | printk("test_bus:4 scl: %d sda: %d\n", getscl(adap), | ||
251 | getsda(adap)); | ||
252 | if ( 0 == getscl(adap) ) { | ||
253 | printk("test_bus: %s SCL stuck low!\n",name); | ||
254 | sclhi(adap); | ||
255 | goto bailout; | ||
256 | } | ||
257 | if ( 0 == getsda(adap) ) { | ||
258 | printk("test_bus: %s SDA unexpected low while SCL high!\n", | ||
259 | name); | ||
260 | goto bailout; | ||
261 | } | ||
262 | printk("test_bus: %s passed test.\n",name); | ||
263 | return 0; | ||
264 | bailout: | ||
265 | sdahi(adap); | ||
266 | sclhi(adap); | ||
267 | return -ENODEV; | ||
268 | #endif | ||
269 | return (0); | ||
270 | } | ||
271 | |||
272 | /* ----- Utility functions | ||
273 | */ | ||
274 | |||
275 | |||
276 | /* Verify the device we want to talk to on the IIC bus really exists. */ | ||
277 | static inline int try_address(struct i2c_algo_iic_data *adap, | ||
278 | unsigned int addr, int retries) | ||
279 | { | ||
280 | int i, ret = -1; | ||
281 | short status; | ||
282 | |||
283 | for (i=0;i<retries;i++) { | ||
284 | iic_outw(adap, ITE_I2CSAR, addr); | ||
285 | iic_start(adap); | ||
286 | if (wait_for_pin(adap, &status) == 0) { | ||
287 | if ((status & ITE_I2CHSR_DNE) == 0) { | ||
288 | iic_stop(adap); | ||
289 | iic_outw(adap, ITE_I2CFCR, ITE_I2CFCR_FLUSH); | ||
290 | ret=1; | ||
291 | break; /* success! */ | ||
292 | } | ||
293 | } | ||
294 | iic_stop(adap); | ||
295 | udelay(adap->udelay); | ||
296 | } | ||
297 | DEB2(if (i) printk("try_address: needed %d retries for 0x%x\n",i, | ||
298 | addr)); | ||
299 | return ret; | ||
300 | } | ||
301 | |||
302 | |||
303 | static int iic_sendbytes(struct i2c_adapter *i2c_adap,const char *buf, | ||
304 | int count) | ||
305 | { | ||
306 | struct i2c_algo_iic_data *adap = i2c_adap->algo_data; | ||
307 | int wrcount=0, timeout; | ||
308 | short status; | ||
309 | int loops, remainder, i, j; | ||
310 | union { | ||
311 | char byte[2]; | ||
312 | unsigned short word; | ||
313 | } tmp; | ||
314 | |||
315 | iic_outw(adap, ITE_I2CSSAR, (unsigned short)buf[wrcount++]); | ||
316 | count--; | ||
317 | if (count == 0) | ||
318 | return -EIO; | ||
319 | |||
320 | loops = count / 32; /* 32-byte FIFO */ | ||
321 | remainder = count % 32; | ||
322 | |||
323 | if(loops) { | ||
324 | for(i=0; i<loops; i++) { | ||
325 | |||
326 | iic_outw(adap, ITE_I2CFBCR, 32); | ||
327 | for(j=0; j<32/2; j++) { | ||
328 | tmp.byte[1] = buf[wrcount++]; | ||
329 | tmp.byte[0] = buf[wrcount++]; | ||
330 | iic_outw(adap, ITE_I2CFDR, tmp.word); | ||
331 | } | ||
332 | |||
333 | /* status FIFO overrun */ | ||
334 | iic_inw(adap, ITE_I2CFSR); | ||
335 | iic_inw(adap, ITE_I2CFBCR); | ||
336 | |||
337 | iic_outw(adap, ITE_I2CHCR, ITE_WRITE); /* Issue WRITE command */ | ||
338 | |||
339 | /* Wait for transmission to complete */ | ||
340 | timeout = wait_for_pin(adap, &status); | ||
341 | if(timeout) { | ||
342 | iic_stop(adap); | ||
343 | printk("iic_sendbytes: %s write timeout.\n", i2c_adap->name); | ||
344 | return -EREMOTEIO; /* got a better one ?? */ | ||
345 | } | ||
346 | if (status & ITE_I2CHSR_DB) { | ||
347 | iic_stop(adap); | ||
348 | printk("iic_sendbytes: %s write error - no ack.\n", i2c_adap->name); | ||
349 | return -EREMOTEIO; /* got a better one ?? */ | ||
350 | } | ||
351 | } | ||
352 | } | ||
353 | if(remainder) { | ||
354 | iic_outw(adap, ITE_I2CFBCR, remainder); | ||
355 | for(i=0; i<remainder/2; i++) { | ||
356 | tmp.byte[1] = buf[wrcount++]; | ||
357 | tmp.byte[0] = buf[wrcount++]; | ||
358 | iic_outw(adap, ITE_I2CFDR, tmp.word); | ||
359 | } | ||
360 | |||
361 | /* status FIFO overrun */ | ||
362 | iic_inw(adap, ITE_I2CFSR); | ||
363 | iic_inw(adap, ITE_I2CFBCR); | ||
364 | |||
365 | iic_outw(adap, ITE_I2CHCR, ITE_WRITE); /* Issue WRITE command */ | ||
366 | |||
367 | timeout = wait_for_pin(adap, &status); | ||
368 | if(timeout) { | ||
369 | iic_stop(adap); | ||
370 | printk("iic_sendbytes: %s write timeout.\n", i2c_adap->name); | ||
371 | return -EREMOTEIO; /* got a better one ?? */ | ||
372 | } | ||
373 | #ifndef STUB_I2C | ||
374 | if (status & ITE_I2CHSR_DB) { | ||
375 | iic_stop(adap); | ||
376 | printk("iic_sendbytes: %s write error - no ack.\n", i2c_adap->name); | ||
377 | return -EREMOTEIO; /* got a better one ?? */ | ||
378 | } | ||
379 | #endif | ||
380 | } | ||
381 | iic_stop(adap); | ||
382 | return wrcount; | ||
383 | } | ||
384 | |||
385 | |||
386 | static int iic_readbytes(struct i2c_adapter *i2c_adap, char *buf, int count, | ||
387 | int sread) | ||
388 | { | ||
389 | int rdcount=0, i, timeout; | ||
390 | short status; | ||
391 | struct i2c_algo_iic_data *adap = i2c_adap->algo_data; | ||
392 | int loops, remainder, j; | ||
393 | union { | ||
394 | char byte[2]; | ||
395 | unsigned short word; | ||
396 | } tmp; | ||
397 | |||
398 | loops = count / 32; /* 32-byte FIFO */ | ||
399 | remainder = count % 32; | ||
400 | |||
401 | if(loops) { | ||
402 | for(i=0; i<loops; i++) { | ||
403 | iic_outw(adap, ITE_I2CFBCR, 32); | ||
404 | if (sread) | ||
405 | iic_outw(adap, ITE_I2CHCR, ITE_SREAD); | ||
406 | else | ||
407 | iic_outw(adap, ITE_I2CHCR, ITE_READ); /* Issue READ command */ | ||
408 | |||
409 | timeout = wait_for_pin(adap, &status); | ||
410 | if(timeout) { | ||
411 | iic_stop(adap); | ||
412 | printk("iic_readbytes: %s read timeout.\n", i2c_adap->name); | ||
413 | return (-1); | ||
414 | } | ||
415 | #ifndef STUB_I2C | ||
416 | if (status & ITE_I2CHSR_DB) { | ||
417 | iic_stop(adap); | ||
418 | printk("iic_readbytes: %s read error - no ack.\n", i2c_adap->name); | ||
419 | return (-1); | ||
420 | } | ||
421 | #endif | ||
422 | |||
423 | timeout = wait_for_fe(adap, &status); | ||
424 | if(timeout) { | ||
425 | iic_stop(adap); | ||
426 | printk("iic_readbytes: %s FIFO is empty\n", i2c_adap->name); | ||
427 | return (-1); | ||
428 | } | ||
429 | |||
430 | for(j=0; j<32/2; j++) { | ||
431 | tmp.word = iic_inw(adap, ITE_I2CFDR); | ||
432 | buf[rdcount++] = tmp.byte[1]; | ||
433 | buf[rdcount++] = tmp.byte[0]; | ||
434 | } | ||
435 | |||
436 | /* status FIFO underrun */ | ||
437 | iic_inw(adap, ITE_I2CFSR); | ||
438 | |||
439 | } | ||
440 | } | ||
441 | |||
442 | |||
443 | if(remainder) { | ||
444 | remainder=(remainder+1)/2 * 2; | ||
445 | iic_outw(adap, ITE_I2CFBCR, remainder); | ||
446 | if (sread) | ||
447 | iic_outw(adap, ITE_I2CHCR, ITE_SREAD); | ||
448 | else | ||
449 | iic_outw(adap, ITE_I2CHCR, ITE_READ); /* Issue READ command */ | ||
450 | |||
451 | timeout = wait_for_pin(adap, &status); | ||
452 | if(timeout) { | ||
453 | iic_stop(adap); | ||
454 | printk("iic_readbytes: %s read timeout.\n", i2c_adap->name); | ||
455 | return (-1); | ||
456 | } | ||
457 | #ifndef STUB_I2C | ||
458 | if (status & ITE_I2CHSR_DB) { | ||
459 | iic_stop(adap); | ||
460 | printk("iic_readbytes: %s read error - no ack.\n", i2c_adap->name); | ||
461 | return (-1); | ||
462 | } | ||
463 | #endif | ||
464 | timeout = wait_for_fe(adap, &status); | ||
465 | if(timeout) { | ||
466 | iic_stop(adap); | ||
467 | printk("iic_readbytes: %s FIFO is empty\n", i2c_adap->name); | ||
468 | return (-1); | ||
469 | } | ||
470 | |||
471 | for(i=0; i<(remainder+1)/2; i++) { | ||
472 | tmp.word = iic_inw(adap, ITE_I2CFDR); | ||
473 | buf[rdcount++] = tmp.byte[1]; | ||
474 | buf[rdcount++] = tmp.byte[0]; | ||
475 | } | ||
476 | |||
477 | /* status FIFO underrun */ | ||
478 | iic_inw(adap, ITE_I2CFSR); | ||
479 | |||
480 | } | ||
481 | |||
482 | iic_stop(adap); | ||
483 | return rdcount; | ||
484 | } | ||
485 | |||
486 | |||
487 | /* This function implements combined transactions. Combined | ||
488 | * transactions consist of combinations of reading and writing blocks of data. | ||
489 | * Each transfer (i.e. a read or a write) is separated by a repeated start | ||
490 | * condition. | ||
491 | */ | ||
492 | #if 0 | ||
493 | static int iic_combined_transaction(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num) | ||
494 | { | ||
495 | int i; | ||
496 | struct i2c_msg *pmsg; | ||
497 | int ret; | ||
498 | |||
499 | DEB2(printk("Beginning combined transaction\n")); | ||
500 | |||
501 | for(i=0; i<(num-1); i++) { | ||
502 | pmsg = &msgs[i]; | ||
503 | if(pmsg->flags & I2C_M_RD) { | ||
504 | DEB2(printk(" This one is a read\n")); | ||
505 | ret = iic_readbytes(i2c_adap, pmsg->buf, pmsg->len, IIC_COMBINED_XFER); | ||
506 | } | ||
507 | else if(!(pmsg->flags & I2C_M_RD)) { | ||
508 | DEB2(printk("This one is a write\n")); | ||
509 | ret = iic_sendbytes(i2c_adap, pmsg->buf, pmsg->len, IIC_COMBINED_XFER); | ||
510 | } | ||
511 | } | ||
512 | /* Last read or write segment needs to be terminated with a stop */ | ||
513 | pmsg = &msgs[i]; | ||
514 | |||
515 | if(pmsg->flags & I2C_M_RD) { | ||
516 | DEB2(printk("Doing the last read\n")); | ||
517 | ret = iic_readbytes(i2c_adap, pmsg->buf, pmsg->len, IIC_SINGLE_XFER); | ||
518 | } | ||
519 | else if(!(pmsg->flags & I2C_M_RD)) { | ||
520 | DEB2(printk("Doing the last write\n")); | ||
521 | ret = iic_sendbytes(i2c_adap, pmsg->buf, pmsg->len, IIC_SINGLE_XFER); | ||
522 | } | ||
523 | |||
524 | return ret; | ||
525 | } | ||
526 | #endif | ||
527 | |||
528 | |||
529 | /* Whenever we initiate a transaction, the first byte clocked | ||
530 | * onto the bus after the start condition is the address (7 bit) of the | ||
531 | * device we want to talk to. This function manipulates the address specified | ||
532 | * so that it makes sense to the hardware when written to the IIC peripheral. | ||
533 | * | ||
534 | * Note: 10 bit addresses are not supported in this driver, although they are | ||
535 | * supported by the hardware. This functionality needs to be implemented. | ||
536 | */ | ||
537 | static inline int iic_doAddress(struct i2c_algo_iic_data *adap, | ||
538 | struct i2c_msg *msg, int retries) | ||
539 | { | ||
540 | unsigned short flags = msg->flags; | ||
541 | unsigned int addr; | ||
542 | int ret; | ||
543 | |||
544 | /* Ten bit addresses not supported right now */ | ||
545 | if ( (flags & I2C_M_TEN) ) { | ||
546 | #if 0 | ||
547 | addr = 0xf0 | (( msg->addr >> 7) & 0x03); | ||
548 | DEB2(printk("addr0: %d\n",addr)); | ||
549 | ret = try_address(adap, addr, retries); | ||
550 | if (ret!=1) { | ||
551 | printk("iic_doAddress: died at extended address code.\n"); | ||
552 | return -EREMOTEIO; | ||
553 | } | ||
554 | iic_outw(adap,msg->addr & 0x7f); | ||
555 | if (ret != 1) { | ||
556 | printk("iic_doAddress: died at 2nd address code.\n"); | ||
557 | return -EREMOTEIO; | ||
558 | } | ||
559 | if ( flags & I2C_M_RD ) { | ||
560 | i2c_repstart(adap); | ||
561 | addr |= 0x01; | ||
562 | ret = try_address(adap, addr, retries); | ||
563 | if (ret!=1) { | ||
564 | printk("iic_doAddress: died at extended address code.\n"); | ||
565 | return -EREMOTEIO; | ||
566 | } | ||
567 | } | ||
568 | #endif | ||
569 | } else { | ||
570 | |||
571 | addr = ( msg->addr << 1 ); | ||
572 | |||
573 | #if 0 | ||
574 | if (flags & I2C_M_RD ) | ||
575 | addr |= 1; | ||
576 | if (flags & I2C_M_REV_DIR_ADDR ) | ||
577 | addr ^= 1; | ||
578 | #endif | ||
579 | |||
580 | if (iic_inw(adap, ITE_I2CSAR) != addr) { | ||
581 | iic_outw(adap, ITE_I2CSAR, addr); | ||
582 | ret = try_address(adap, addr, retries); | ||
583 | if (ret!=1) { | ||
584 | printk("iic_doAddress: died at address code.\n"); | ||
585 | return -EREMOTEIO; | ||
586 | } | ||
587 | } | ||
588 | |||
589 | } | ||
590 | |||
591 | return 0; | ||
592 | } | ||
593 | |||
594 | |||
595 | /* Description: Prepares the controller for a transaction (clearing status | ||
596 | * registers, data buffers, etc), and then calls either iic_readbytes or | ||
597 | * iic_sendbytes to do the actual transaction. | ||
598 | * | ||
599 | * still to be done: Before we issue a transaction, we should | ||
600 | * verify that the bus is not busy or in some unknown state. | ||
601 | */ | ||
602 | static int iic_xfer(struct i2c_adapter *i2c_adap, | ||
603 | struct i2c_msg *msgs, | ||
604 | int num) | ||
605 | { | ||
606 | struct i2c_algo_iic_data *adap = i2c_adap->algo_data; | ||
607 | struct i2c_msg *pmsg; | ||
608 | int i = 0; | ||
609 | int ret, timeout; | ||
610 | |||
611 | pmsg = &msgs[i]; | ||
612 | |||
613 | if(!pmsg->len) { | ||
614 | DEB2(printk("iic_xfer: read/write length is 0\n");) | ||
615 | return -EIO; | ||
616 | } | ||
617 | if(!(pmsg->flags & I2C_M_RD) && (!(pmsg->len)%2) ) { | ||
618 | DEB2(printk("iic_xfer: write buffer length is not odd\n");) | ||
619 | return -EIO; | ||
620 | } | ||
621 | |||
622 | /* Wait for any pending transfers to complete */ | ||
623 | timeout = wait_for_bb(adap); | ||
624 | if (timeout) { | ||
625 | DEB2(printk("iic_xfer: Timeout waiting for host not busy\n");) | ||
626 | return -EIO; | ||
627 | } | ||
628 | |||
629 | /* Flush FIFO */ | ||
630 | iic_outw(adap, ITE_I2CFCR, ITE_I2CFCR_FLUSH); | ||
631 | |||
632 | /* Load address */ | ||
633 | ret = iic_doAddress(adap, pmsg, i2c_adap->retries); | ||
634 | if (ret) | ||
635 | return -EIO; | ||
636 | |||
637 | #if 0 | ||
638 | /* Combined transaction (read and write) */ | ||
639 | if(num > 1) { | ||
640 | DEB2(printk("iic_xfer: Call combined transaction\n")); | ||
641 | ret = iic_combined_transaction(i2c_adap, msgs, num); | ||
642 | } | ||
643 | #endif | ||
644 | |||
645 | DEB3(printk("iic_xfer: Msg %d, addr=0x%x, flags=0x%x, len=%d\n", | ||
646 | i, msgs[i].addr, msgs[i].flags, msgs[i].len);) | ||
647 | |||
648 | if(pmsg->flags & I2C_M_RD) /* Read */ | ||
649 | ret = iic_readbytes(i2c_adap, pmsg->buf, pmsg->len, 0); | ||
650 | else { /* Write */ | ||
651 | udelay(1000); | ||
652 | ret = iic_sendbytes(i2c_adap, pmsg->buf, pmsg->len); | ||
653 | } | ||
654 | |||
655 | if (ret != pmsg->len) | ||
656 | DEB3(printk("iic_xfer: error or fail on read/write %d bytes.\n",ret)); | ||
657 | else | ||
658 | DEB3(printk("iic_xfer: read/write %d bytes.\n",ret)); | ||
659 | |||
660 | return ret; | ||
661 | } | ||
662 | |||
663 | |||
664 | /* Implements device specific ioctls. Higher level ioctls can | ||
665 | * be found in i2c-core.c and are typical of any i2c controller (specifying | ||
666 | * slave address, timeouts, etc). These ioctls take advantage of any hardware | ||
667 | * features built into the controller for which this algorithm-adapter set | ||
668 | * was written. These ioctls allow you to take control of the data and clock | ||
669 | * lines and set the either high or low, | ||
670 | * similar to a GPIO pin. | ||
671 | */ | ||
672 | static int algo_control(struct i2c_adapter *adapter, | ||
673 | unsigned int cmd, unsigned long arg) | ||
674 | { | ||
675 | |||
676 | struct i2c_algo_iic_data *adap = adapter->algo_data; | ||
677 | struct i2c_iic_msg s_msg; | ||
678 | char *buf; | ||
679 | int ret; | ||
680 | |||
681 | if (cmd == I2C_SREAD) { | ||
682 | if(copy_from_user(&s_msg, (struct i2c_iic_msg *)arg, | ||
683 | sizeof(struct i2c_iic_msg))) | ||
684 | return -EFAULT; | ||
685 | buf = kmalloc(s_msg.len, GFP_KERNEL); | ||
686 | if (buf== NULL) | ||
687 | return -ENOMEM; | ||
688 | |||
689 | /* Flush FIFO */ | ||
690 | iic_outw(adap, ITE_I2CFCR, ITE_I2CFCR_FLUSH); | ||
691 | |||
692 | /* Load address */ | ||
693 | iic_outw(adap, ITE_I2CSAR,s_msg.addr<<1); | ||
694 | iic_outw(adap, ITE_I2CSSAR,s_msg.waddr & 0xff); | ||
695 | |||
696 | ret = iic_readbytes(adapter, buf, s_msg.len, 1); | ||
697 | if (ret>=0) { | ||
698 | if(copy_to_user( s_msg.buf, buf, s_msg.len) ) | ||
699 | ret = -EFAULT; | ||
700 | } | ||
701 | kfree(buf); | ||
702 | } | ||
703 | return 0; | ||
704 | } | ||
705 | |||
706 | |||
707 | static u32 iic_func(struct i2c_adapter *adap) | ||
708 | { | ||
709 | return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR | | ||
710 | I2C_FUNC_PROTOCOL_MANGLING; | ||
711 | } | ||
712 | |||
713 | /* -----exported algorithm data: ------------------------------------- */ | ||
714 | |||
715 | static struct i2c_algorithm iic_algo = { | ||
716 | .master_xfer = iic_xfer, | ||
717 | .algo_control = algo_control, /* ioctl */ | ||
718 | .functionality = iic_func, | ||
719 | }; | ||
720 | |||
721 | |||
722 | /* | ||
723 | * registering functions to load algorithms at runtime | ||
724 | */ | ||
725 | int i2c_iic_add_bus(struct i2c_adapter *adap) | ||
726 | { | ||
727 | struct i2c_algo_iic_data *iic_adap = adap->algo_data; | ||
728 | |||
729 | if (iic_test) { | ||
730 | int ret = test_bus(iic_adap, adap->name); | ||
731 | if (ret<0) | ||
732 | return -ENODEV; | ||
733 | } | ||
734 | |||
735 | DEB2(printk("i2c-algo-ite: hw routines for %s registered.\n", | ||
736 | adap->name)); | ||
737 | |||
738 | /* register new adapter to i2c module... */ | ||
739 | adap->algo = &iic_algo; | ||
740 | |||
741 | adap->timeout = 100; /* default values, should */ | ||
742 | adap->retries = 3; /* be replaced by defines */ | ||
743 | adap->flags = 0; | ||
744 | |||
745 | iic_init(iic_adap); | ||
746 | return i2c_add_adapter(adap); | ||
747 | } | ||
748 | |||
749 | |||
750 | int i2c_iic_del_bus(struct i2c_adapter *adap) | ||
751 | { | ||
752 | int res; | ||
753 | if ((res = i2c_del_adapter(adap)) < 0) | ||
754 | return res; | ||
755 | DEB2(printk("i2c-algo-ite: adapter unregistered: %s\n",adap->name)); | ||
756 | |||
757 | return 0; | ||
758 | } | ||
759 | |||
760 | |||
761 | int __init i2c_algo_iic_init (void) | ||
762 | { | ||
763 | printk(KERN_INFO "ITE iic (i2c) algorithm module\n"); | ||
764 | return 0; | ||
765 | } | ||
766 | |||
767 | |||
768 | void i2c_algo_iic_exit(void) | ||
769 | { | ||
770 | return; | ||
771 | } | ||
772 | |||
773 | |||
774 | EXPORT_SYMBOL(i2c_iic_add_bus); | ||
775 | EXPORT_SYMBOL(i2c_iic_del_bus); | ||
776 | |||
777 | /* The MODULE_* macros resolve to nothing if MODULES is not defined | ||
778 | * when this file is compiled. | ||
779 | */ | ||
780 | MODULE_AUTHOR("MontaVista Software <www.mvista.com>"); | ||
781 | MODULE_DESCRIPTION("ITE iic algorithm"); | ||
782 | MODULE_LICENSE("GPL"); | ||
783 | |||
784 | module_param(iic_test, bool, 0); | ||
785 | module_param(i2c_debug, int, S_IRUGO | S_IWUSR); | ||
786 | |||
787 | MODULE_PARM_DESC(iic_test, "Test if the I2C bus is available"); | ||
788 | MODULE_PARM_DESC(i2c_debug, | ||
789 | "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol"); | ||
790 | |||
791 | |||
792 | /* This function resolves to init_module (the function invoked when a module | ||
793 | * is loaded via insmod) when this file is compiled with MODULES defined. | ||
794 | * Otherwise (i.e. if you want this driver statically linked to the kernel), | ||
795 | * a pointer to this function is stored in a table and called | ||
796 | * during the initialization of the kernel (in do_basic_setup in /init/main.c) | ||
797 | * | ||
798 | * All this functionality is complements of the macros defined in linux/init.h | ||
799 | */ | ||
800 | module_init(i2c_algo_iic_init); | ||
801 | |||
802 | |||
803 | /* If MODULES is defined when this file is compiled, then this function will | ||
804 | * resolved to cleanup_module. | ||
805 | */ | ||
806 | module_exit(i2c_algo_iic_exit); | ||
diff --git a/drivers/i2c/algos/i2c-algo-ite.h b/drivers/i2c/algos/i2c-algo-ite.h deleted file mode 100644 index a8ca3c9b546a..000000000000 --- a/drivers/i2c/algos/i2c-algo-ite.h +++ /dev/null | |||
@@ -1,117 +0,0 @@ | |||
1 | /* | ||
2 | -------------------------------------------------------------------- | ||
3 | i2c-ite.h: Global defines for the I2C controller on board the | ||
4 | ITE MIPS processor. | ||
5 | -------------------------------------------------------------------- | ||
6 | Hai-Pao Fan, MontaVista Software, Inc. | ||
7 | hpfan@mvista.com or source@mvista.com | ||
8 | |||
9 | Copyright 2001 MontaVista Software Inc. | ||
10 | |||
11 | * This program is free software; you can redistribute it and/or modify it | ||
12 | * under the terms of the GNU General Public License as published by the | ||
13 | * Free Software Foundation; either version 2 of the License, or (at your | ||
14 | * option) any later version. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
19 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
22 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
23 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | * You should have received a copy of the GNU General Public License along | ||
28 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
29 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
30 | |||
31 | */ | ||
32 | |||
33 | #ifndef I2C_ITE_H | ||
34 | #define I2C_ITE_H 1 | ||
35 | |||
36 | #include <asm/it8172/it8172.h> | ||
37 | |||
38 | /* I2C Registers */ | ||
39 | #define ITE_I2CHCR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x30 | ||
40 | #define ITE_I2CHSR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x34 | ||
41 | #define ITE_I2CSAR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x38 | ||
42 | #define ITE_I2CSSAR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x3c | ||
43 | #define ITE_I2CCKCNT IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x48 | ||
44 | #define ITE_I2CSHDR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x4c | ||
45 | #define ITE_I2CRSUR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x50 | ||
46 | #define ITE_I2CPSUR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x54 | ||
47 | |||
48 | #define ITE_I2CFDR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x70 | ||
49 | #define ITE_I2CFBCR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x74 | ||
50 | #define ITE_I2CFCR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x78 | ||
51 | #define ITE_I2CFSR IT8172_PCI_IO_BASE + IT_I2C_BASE + 0x7c | ||
52 | |||
53 | |||
54 | /* Host Control Register ITE_I2CHCR */ | ||
55 | #define ITE_I2CHCR_HCE 0x01 /* Enable I2C Host Controller */ | ||
56 | #define ITE_I2CHCR_IE 0x02 /* Enable the interrupt after completing | ||
57 | the current transaction */ | ||
58 | #define ITE_I2CHCR_CP_W 0x00 /* bit2-4 000 - Write */ | ||
59 | #define ITE_I2CHCR_CP_R 0x08 /* 010 - Current address read */ | ||
60 | #define ITE_I2CHCR_CP_S 0x10 /* 100 - Sequential read */ | ||
61 | #define ITE_I2CHCR_ST 0x20 /* Initiates the I2C host controller to execute | ||
62 | the command and send the data programmed in | ||
63 | all required registers to I2C bus */ | ||
64 | #define ITE_CMD ITE_I2CHCR_HCE | ITE_I2CHCR_IE | ITE_I2CHCR_ST | ||
65 | #define ITE_WRITE ITE_CMD | ITE_I2CHCR_CP_W | ||
66 | #define ITE_READ ITE_CMD | ITE_I2CHCR_CP_R | ||
67 | #define ITE_SREAD ITE_CMD | ITE_I2CHCR_CP_S | ||
68 | |||
69 | /* Host Status Register ITE_I2CHSR */ | ||
70 | #define ITE_I2CHSR_DB 0x01 /* Device is busy, receives NACK response except | ||
71 | in the first and last bytes */ | ||
72 | #define ITE_I2CHSR_DNE 0x02 /* Target address on I2C bus does not exist */ | ||
73 | #define ITE_I2CHSR_TDI 0x04 /* R/W Transaction on I2C bus was completed */ | ||
74 | #define ITE_I2CHSR_HB 0x08 /* Host controller is processing transactions */ | ||
75 | #define ITE_I2CHSR_FER 0x10 /* Error occurs in the FIFO */ | ||
76 | |||
77 | /* Slave Address Register ITE_I2CSAR */ | ||
78 | #define ITE_I2CSAR_SA_MASK 0xfe /* Target I2C device address */ | ||
79 | #define ITE_I2CSAR_ASO 0x0100 /* Output 1/0 to I2CAS port when the | ||
80 | next slave address is addressed */ | ||
81 | |||
82 | /* Slave Sub-address Register ITE_I2CSSAR */ | ||
83 | #define ITE_I2CSSAR_SUBA_MASK 0xff /* Target I2C device sub-address */ | ||
84 | |||
85 | /* Clock Counter Register ITE_I2CCKCNT */ | ||
86 | #define ITE_I2CCKCNT_STOP 0x00 /* stop I2C clock */ | ||
87 | #define ITE_I2CCKCNT_HPCC_MASK 0x7f /* SCL high period counter */ | ||
88 | #define ITE_I2CCKCNT_LPCC_MASK 0x7f00 /* SCL low period counter */ | ||
89 | |||
90 | /* START Hold Time Register ITE_I2CSHDR */ | ||
91 | /* value is counted based on 16 MHz internal clock */ | ||
92 | #define ITE_I2CSHDR_FM 0x0a /* START condition at fast mode */ | ||
93 | #define ITE_I2CSHDR_SM 0x47 /* START contition at standard mode */ | ||
94 | |||
95 | /* (Repeated) START Setup Time Register ITE_I2CRSUR */ | ||
96 | /* value is counted based on 16 MHz internal clock */ | ||
97 | #define ITE_I2CRSUR_FM 0x0a /* repeated START condition at fast mode */ | ||
98 | #define ITE_I2CRSUR_SM 0x50 /* repeated START condition at standard mode */ | ||
99 | |||
100 | /* STOP setup Time Register ITE_I2CPSUR */ | ||
101 | |||
102 | /* FIFO Data Register ITE_I2CFDR */ | ||
103 | #define ITE_I2CFDR_MASK 0xff | ||
104 | |||
105 | /* FIFO Byte Count Register ITE_I2CFBCR */ | ||
106 | #define ITE_I2CFBCR_MASK 0x3f | ||
107 | |||
108 | /* FIFO Control Register ITE_I2CFCR */ | ||
109 | #define ITE_I2CFCR_FLUSH 0x01 /* Flush FIFO and reset the FIFO point | ||
110 | and I2CFSR */ | ||
111 | /* FIFO Status Register ITE_I2CFSR */ | ||
112 | #define ITE_I2CFSR_FO 0x01 /* FIFO is overrun when write */ | ||
113 | #define ITE_I2CFSR_FU 0x02 /* FIFO is underrun when read */ | ||
114 | #define ITE_I2CFSR_FF 0x04 /* FIFO is full when write */ | ||
115 | #define ITE_I2CFSR_FE 0x08 /* FIFO is empty when read */ | ||
116 | |||
117 | #endif /* I2C_ITE_H */ | ||
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index 9081c9fbcd29..36fdf971f080 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c | |||
@@ -381,14 +381,7 @@ int i2c_pca_add_bus(struct i2c_adapter *adap) | |||
381 | 381 | ||
382 | return rval; | 382 | return rval; |
383 | } | 383 | } |
384 | |||
385 | int i2c_pca_del_bus(struct i2c_adapter *adap) | ||
386 | { | ||
387 | return i2c_del_adapter(adap); | ||
388 | } | ||
389 | |||
390 | EXPORT_SYMBOL(i2c_pca_add_bus); | 384 | EXPORT_SYMBOL(i2c_pca_add_bus); |
391 | EXPORT_SYMBOL(i2c_pca_del_bus); | ||
392 | 385 | ||
393 | MODULE_AUTHOR("Ian Campbell <icampbell@arcom.com>"); | 386 | MODULE_AUTHOR("Ian Campbell <icampbell@arcom.com>"); |
394 | MODULE_DESCRIPTION("I2C-Bus PCA9564 algorithm"); | 387 | MODULE_DESCRIPTION("I2C-Bus PCA9564 algorithm"); |
diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c index 3b2003398966..ecb2c2d7d540 100644 --- a/drivers/i2c/algos/i2c-algo-pcf.c +++ b/drivers/i2c/algos/i2c-algo-pcf.c | |||
@@ -486,15 +486,7 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap) | |||
486 | 486 | ||
487 | return rval; | 487 | return rval; |
488 | } | 488 | } |
489 | |||
490 | |||
491 | int i2c_pcf_del_bus(struct i2c_adapter *adap) | ||
492 | { | ||
493 | return i2c_del_adapter(adap); | ||
494 | } | ||
495 | |||
496 | EXPORT_SYMBOL(i2c_pcf_add_bus); | 489 | EXPORT_SYMBOL(i2c_pcf_add_bus); |
497 | EXPORT_SYMBOL(i2c_pcf_del_bus); | ||
498 | 490 | ||
499 | MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); | 491 | MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); |
500 | MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm"); | 492 | MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm"); |
diff --git a/drivers/i2c/algos/i2c-algo-sgi.c b/drivers/i2c/algos/i2c-algo-sgi.c index 490d99997fd0..ac2d5053078a 100644 --- a/drivers/i2c/algos/i2c-algo-sgi.c +++ b/drivers/i2c/algos/i2c-algo-sgi.c | |||
@@ -171,15 +171,7 @@ int i2c_sgi_add_bus(struct i2c_adapter *adap) | |||
171 | 171 | ||
172 | return i2c_add_adapter(adap); | 172 | return i2c_add_adapter(adap); |
173 | } | 173 | } |
174 | |||
175 | |||
176 | int i2c_sgi_del_bus(struct i2c_adapter *adap) | ||
177 | { | ||
178 | return i2c_del_adapter(adap); | ||
179 | } | ||
180 | |||
181 | EXPORT_SYMBOL(i2c_sgi_add_bus); | 174 | EXPORT_SYMBOL(i2c_sgi_add_bus); |
182 | EXPORT_SYMBOL(i2c_sgi_del_bus); | ||
183 | 175 | ||
184 | MODULE_AUTHOR("Ladislav Michl <ladis@linux-mips.org>"); | 176 | MODULE_AUTHOR("Ladislav Michl <ladis@linux-mips.org>"); |
185 | MODULE_DESCRIPTION("I2C-Bus SGI algorithm"); | 177 | MODULE_DESCRIPTION("I2C-Bus SGI algorithm"); |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 90f91d039ee2..e1989f3a2684 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -74,6 +74,13 @@ config I2C_AMD8111 | |||
74 | This driver can also be built as a module. If so, the module | 74 | This driver can also be built as a module. If so, the module |
75 | will be called i2c-amd8111. | 75 | will be called i2c-amd8111. |
76 | 76 | ||
77 | config I2C_AT91 | ||
78 | tristate "Atmel AT91 I2C Two-Wire interface (TWI)" | ||
79 | depends on I2C && ARCH_AT91 && EXPERIMENTAL | ||
80 | help | ||
81 | This supports the use of the I2C interface on Atmel AT91 | ||
82 | processors. | ||
83 | |||
77 | config I2C_AU1550 | 84 | config I2C_AU1550 |
78 | tristate "Au1550/Au1200 SMBus interface" | 85 | tristate "Au1550/Au1200 SMBus interface" |
79 | depends on I2C && (SOC_AU1550 || SOC_AU1200) | 86 | depends on I2C && (SOC_AU1550 || SOC_AU1200) |
@@ -209,18 +216,6 @@ config I2C_ISA | |||
209 | tristate | 216 | tristate |
210 | depends on I2C | 217 | depends on I2C |
211 | 218 | ||
212 | config I2C_ITE | ||
213 | tristate "ITE I2C Adapter" | ||
214 | depends on I2C && MIPS_ITE8172 | ||
215 | select I2C_ALGOITE | ||
216 | help | ||
217 | This supports the ITE8172 I2C peripheral found on some MIPS | ||
218 | systems. Say Y if you have one of these. You should also say Y for | ||
219 | the ITE I2C driver algorithm support above. | ||
220 | |||
221 | This support is also available as a module. If so, the module | ||
222 | will be called i2c-ite. | ||
223 | |||
224 | config I2C_IXP4XX | 219 | config I2C_IXP4XX |
225 | tristate "IXP4xx GPIO-Based I2C Interface" | 220 | tristate "IXP4xx GPIO-Based I2C Interface" |
226 | depends on I2C && ARCH_IXP4XX | 221 | depends on I2C && ARCH_IXP4XX |
@@ -481,6 +476,17 @@ config I2C_STUB | |||
481 | 476 | ||
482 | If you don't know what to do here, definitely say N. | 477 | If you don't know what to do here, definitely say N. |
483 | 478 | ||
479 | config I2C_VERSATILE | ||
480 | tristate "ARM Versatile/Realview I2C bus support" | ||
481 | depends on I2C && (ARCH_VERSATILE || ARCH_REALVIEW) | ||
482 | select I2C_ALGOBIT | ||
483 | help | ||
484 | Say yes if you want to support the I2C serial bus on ARMs Versatile | ||
485 | range of platforms. | ||
486 | |||
487 | This driver can also be built as a module. If so, the module | ||
488 | will be called i2c-versatile. | ||
489 | |||
484 | config I2C_VIA | 490 | config I2C_VIA |
485 | tristate "VIA 82C586B" | 491 | tristate "VIA 82C586B" |
486 | depends on I2C && PCI && EXPERIMENTAL | 492 | depends on I2C && PCI && EXPERIMENTAL |
@@ -548,4 +554,23 @@ config I2C_MV64XXX | |||
548 | This driver can also be built as a module. If so, the module | 554 | This driver can also be built as a module. If so, the module |
549 | will be called i2c-mv64xxx. | 555 | will be called i2c-mv64xxx. |
550 | 556 | ||
557 | config I2C_PNX | ||
558 | tristate "I2C bus support for Philips PNX targets" | ||
559 | depends on ARCH_PNX4008 && I2C | ||
560 | help | ||
561 | This driver supports the Philips IP3204 I2C IP block master and/or | ||
562 | slave controller | ||
563 | |||
564 | This driver can also be built as a module. If so, the module | ||
565 | will be called i2c-pnx. | ||
566 | |||
567 | config I2C_PNX_EARLY | ||
568 | bool "Early initialization for I2C on PNXxxxx" | ||
569 | depends on I2C_PNX=y | ||
570 | help | ||
571 | Under certain circumstances one may need to make sure I2C on PNXxxxx | ||
572 | is initialized earlier than some other driver that depends on it | ||
573 | (for instance, that might be USB in case of PNX4008). With this | ||
574 | option turned on you can guarantee that. | ||
575 | |||
551 | endmenu | 576 | endmenu |
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index 493c87289b62..37196c1d0794 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile | |||
@@ -8,6 +8,7 @@ obj-$(CONFIG_I2C_ALI15X3) += i2c-ali15x3.o | |||
8 | obj-$(CONFIG_I2C_AMD756) += i2c-amd756.o | 8 | obj-$(CONFIG_I2C_AMD756) += i2c-amd756.o |
9 | obj-$(CONFIG_I2C_AMD756_S4882) += i2c-amd756-s4882.o | 9 | obj-$(CONFIG_I2C_AMD756_S4882) += i2c-amd756-s4882.o |
10 | obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o | 10 | obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o |
11 | obj-$(CONFIG_I2C_AT91) += i2c-at91.o | ||
11 | obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o | 12 | obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o |
12 | obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o | 13 | obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o |
13 | obj-$(CONFIG_I2C_HYDRA) += i2c-hydra.o | 14 | obj-$(CONFIG_I2C_HYDRA) += i2c-hydra.o |
@@ -16,7 +17,6 @@ obj-$(CONFIG_I2C_I810) += i2c-i810.o | |||
16 | obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o | 17 | obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o |
17 | obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o | 18 | obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o |
18 | obj-$(CONFIG_I2C_ISA) += i2c-isa.o | 19 | obj-$(CONFIG_I2C_ISA) += i2c-isa.o |
19 | obj-$(CONFIG_I2C_ITE) += i2c-ite.o | ||
20 | obj-$(CONFIG_I2C_IXP2000) += i2c-ixp2000.o | 20 | obj-$(CONFIG_I2C_IXP2000) += i2c-ixp2000.o |
21 | obj-$(CONFIG_I2C_IXP4XX) += i2c-ixp4xx.o | 21 | obj-$(CONFIG_I2C_IXP4XX) += i2c-ixp4xx.o |
22 | obj-$(CONFIG_I2C_POWERMAC) += i2c-powermac.o | 22 | obj-$(CONFIG_I2C_POWERMAC) += i2c-powermac.o |
@@ -29,6 +29,7 @@ obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o | |||
29 | obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o | 29 | obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o |
30 | obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o | 30 | obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o |
31 | obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o | 31 | obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o |
32 | obj-$(CONFIG_I2C_PNX) += i2c-pnx.o | ||
32 | obj-$(CONFIG_I2C_PROSAVAGE) += i2c-prosavage.o | 33 | obj-$(CONFIG_I2C_PROSAVAGE) += i2c-prosavage.o |
33 | obj-$(CONFIG_I2C_PXA) += i2c-pxa.o | 34 | obj-$(CONFIG_I2C_PXA) += i2c-pxa.o |
34 | obj-$(CONFIG_I2C_RPXLITE) += i2c-rpx.o | 35 | obj-$(CONFIG_I2C_RPXLITE) += i2c-rpx.o |
@@ -39,6 +40,7 @@ obj-$(CONFIG_I2C_SIS5595) += i2c-sis5595.o | |||
39 | obj-$(CONFIG_I2C_SIS630) += i2c-sis630.o | 40 | obj-$(CONFIG_I2C_SIS630) += i2c-sis630.o |
40 | obj-$(CONFIG_I2C_SIS96X) += i2c-sis96x.o | 41 | obj-$(CONFIG_I2C_SIS96X) += i2c-sis96x.o |
41 | obj-$(CONFIG_I2C_STUB) += i2c-stub.o | 42 | obj-$(CONFIG_I2C_STUB) += i2c-stub.o |
43 | obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o | ||
42 | obj-$(CONFIG_I2C_VIA) += i2c-via.o | 44 | obj-$(CONFIG_I2C_VIA) += i2c-via.o |
43 | obj-$(CONFIG_I2C_VIAPRO) += i2c-viapro.o | 45 | obj-$(CONFIG_I2C_VIAPRO) += i2c-viapro.o |
44 | obj-$(CONFIG_I2C_VOODOO3) += i2c-voodoo3.o | 46 | obj-$(CONFIG_I2C_VOODOO3) += i2c-voodoo3.o |
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c new file mode 100644 index 000000000000..67f91bdda089 --- /dev/null +++ b/drivers/i2c/busses/i2c-at91.c | |||
@@ -0,0 +1,325 @@ | |||
1 | /* | ||
2 | i2c Support for Atmel's AT91 Two-Wire Interface (TWI) | ||
3 | |||
4 | Copyright (C) 2004 Rick Bronson | ||
5 | Converted to 2.6 by Andrew Victor <andrew@sanpeople.com> | ||
6 | |||
7 | Borrowed heavily from original work by: | ||
8 | Copyright (C) 2000 Philip Edelbrock <phil@stimpy.netroedge.com> | ||
9 | |||
10 | This program is free software; you can redistribute it and/or modify | ||
11 | it under the terms of the GNU General Public License as published by | ||
12 | the Free Software Foundation; either version 2 of the License, or | ||
13 | (at your option) any later version. | ||
14 | */ | ||
15 | |||
16 | #include <linux/module.h> | ||
17 | #include <linux/version.h> | ||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/pci.h> | ||
21 | #include <linux/types.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include <linux/i2c.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/clk.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | |||
28 | #include <asm/io.h> | ||
29 | |||
30 | #include <asm/arch/at91_twi.h> | ||
31 | #include <asm/arch/board.h> | ||
32 | #include <asm/arch/cpu.h> | ||
33 | |||
34 | #define TWI_CLOCK 100000 /* Hz. max 400 Kbits/sec */ | ||
35 | |||
36 | |||
37 | static struct clk *twi_clk; | ||
38 | static void __iomem *twi_base; | ||
39 | |||
40 | #define at91_twi_read(reg) __raw_readl(twi_base + (reg)) | ||
41 | #define at91_twi_write(reg, val) __raw_writel((val), twi_base + (reg)) | ||
42 | |||
43 | |||
44 | /* | ||
45 | * Initialize the TWI hardware registers. | ||
46 | */ | ||
47 | static void __devinit at91_twi_hwinit(void) | ||
48 | { | ||
49 | unsigned long cdiv, ckdiv; | ||
50 | |||
51 | at91_twi_write(AT91_TWI_IDR, 0xffffffff); /* Disable all interrupts */ | ||
52 | at91_twi_write(AT91_TWI_CR, AT91_TWI_SWRST); /* Reset peripheral */ | ||
53 | at91_twi_write(AT91_TWI_CR, AT91_TWI_MSEN); /* Set Master mode */ | ||
54 | |||
55 | /* Calcuate clock dividers */ | ||
56 | cdiv = (clk_get_rate(twi_clk) / (2 * TWI_CLOCK)) - 3; | ||
57 | cdiv = cdiv + 1; /* round up */ | ||
58 | ckdiv = 0; | ||
59 | while (cdiv > 255) { | ||
60 | ckdiv++; | ||
61 | cdiv = cdiv >> 1; | ||
62 | } | ||
63 | |||
64 | if (cpu_is_at91rm9200()) { /* AT91RM9200 Errata #22 */ | ||
65 | if (ckdiv > 5) { | ||
66 | printk(KERN_ERR "AT91 I2C: Invalid TWI_CLOCK value!\n"); | ||
67 | ckdiv = 5; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | at91_twi_write(AT91_TWI_CWGR, (ckdiv << 16) | (cdiv << 8) | cdiv); | ||
72 | } | ||
73 | |||
74 | /* | ||
75 | * Poll the i2c status register until the specified bit is set. | ||
76 | * Returns 0 if timed out (100 msec). | ||
77 | */ | ||
78 | static short at91_poll_status(unsigned long bit) | ||
79 | { | ||
80 | int loop_cntr = 10000; | ||
81 | |||
82 | do { | ||
83 | udelay(10); | ||
84 | } while (!(at91_twi_read(AT91_TWI_SR) & bit) && (--loop_cntr > 0)); | ||
85 | |||
86 | return (loop_cntr > 0); | ||
87 | } | ||
88 | |||
89 | static int xfer_read(struct i2c_adapter *adap, unsigned char *buf, int length) | ||
90 | { | ||
91 | /* Send Start */ | ||
92 | at91_twi_write(AT91_TWI_CR, AT91_TWI_START); | ||
93 | |||
94 | /* Read data */ | ||
95 | while (length--) { | ||
96 | if (!length) /* need to send Stop before reading last byte */ | ||
97 | at91_twi_write(AT91_TWI_CR, AT91_TWI_STOP); | ||
98 | if (!at91_poll_status(AT91_TWI_RXRDY)) { | ||
99 | dev_dbg(&adap->dev, "RXRDY timeout\n"); | ||
100 | return -ETIMEDOUT; | ||
101 | } | ||
102 | *buf++ = (at91_twi_read(AT91_TWI_RHR) & 0xff); | ||
103 | } | ||
104 | |||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | static int xfer_write(struct i2c_adapter *adap, unsigned char *buf, int length) | ||
109 | { | ||
110 | /* Load first byte into transmitter */ | ||
111 | at91_twi_write(AT91_TWI_THR, *buf++); | ||
112 | |||
113 | /* Send Start */ | ||
114 | at91_twi_write(AT91_TWI_CR, AT91_TWI_START); | ||
115 | |||
116 | do { | ||
117 | if (!at91_poll_status(AT91_TWI_TXRDY)) { | ||
118 | dev_dbg(&adap->dev, "TXRDY timeout\n"); | ||
119 | return -ETIMEDOUT; | ||
120 | } | ||
121 | |||
122 | length--; /* byte was transmitted */ | ||
123 | |||
124 | if (length > 0) /* more data to send? */ | ||
125 | at91_twi_write(AT91_TWI_THR, *buf++); | ||
126 | } while (length); | ||
127 | |||
128 | /* Send Stop */ | ||
129 | at91_twi_write(AT91_TWI_CR, AT91_TWI_STOP); | ||
130 | |||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | /* | ||
135 | * Generic i2c master transfer entrypoint. | ||
136 | * | ||
137 | * Note: We do not use Atmel's feature of storing the "internal device address". | ||
138 | * Instead the "internal device address" has to be written using a seperate | ||
139 | * i2c message. | ||
140 | * http://lists.arm.linux.org.uk/pipermail/linux-arm-kernel/2004-September/024411.html | ||
141 | */ | ||
142 | static int at91_xfer(struct i2c_adapter *adap, struct i2c_msg *pmsg, int num) | ||
143 | { | ||
144 | int i, ret; | ||
145 | |||
146 | dev_dbg(&adap->dev, "at91_xfer: processing %d messages:\n", num); | ||
147 | |||
148 | for (i = 0; i < num; i++) { | ||
149 | dev_dbg(&adap->dev, " #%d: %sing %d byte%s %s 0x%02x\n", i, | ||
150 | pmsg->flags & I2C_M_RD ? "read" : "writ", | ||
151 | pmsg->len, pmsg->len > 1 ? "s" : "", | ||
152 | pmsg->flags & I2C_M_RD ? "from" : "to", pmsg->addr); | ||
153 | |||
154 | at91_twi_write(AT91_TWI_MMR, (pmsg->addr << 16) | ||
155 | | ((pmsg->flags & I2C_M_RD) ? AT91_TWI_MREAD : 0)); | ||
156 | |||
157 | if (pmsg->len && pmsg->buf) { /* sanity check */ | ||
158 | if (pmsg->flags & I2C_M_RD) | ||
159 | ret = xfer_read(adap, pmsg->buf, pmsg->len); | ||
160 | else | ||
161 | ret = xfer_write(adap, pmsg->buf, pmsg->len); | ||
162 | |||
163 | if (ret) | ||
164 | return ret; | ||
165 | |||
166 | /* Wait until transfer is finished */ | ||
167 | if (!at91_poll_status(AT91_TWI_TXCOMP)) { | ||
168 | dev_dbg(&adap->dev, "TXCOMP timeout\n"); | ||
169 | return -ETIMEDOUT; | ||
170 | } | ||
171 | } | ||
172 | dev_dbg(&adap->dev, "transfer complete\n"); | ||
173 | pmsg++; /* next message */ | ||
174 | } | ||
175 | return i; | ||
176 | } | ||
177 | |||
178 | /* | ||
179 | * Return list of supported functionality. | ||
180 | */ | ||
181 | static u32 at91_func(struct i2c_adapter *adapter) | ||
182 | { | ||
183 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; | ||
184 | } | ||
185 | |||
186 | static struct i2c_algorithm at91_algorithm = { | ||
187 | .master_xfer = at91_xfer, | ||
188 | .functionality = at91_func, | ||
189 | }; | ||
190 | |||
191 | /* | ||
192 | * Main initialization routine. | ||
193 | */ | ||
194 | static int __devinit at91_i2c_probe(struct platform_device *pdev) | ||
195 | { | ||
196 | struct i2c_adapter *adapter; | ||
197 | struct resource *res; | ||
198 | int rc; | ||
199 | |||
200 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
201 | if (!res) | ||
202 | return -ENXIO; | ||
203 | |||
204 | if (!request_mem_region(res->start, res->end - res->start + 1, "at91_i2c")) | ||
205 | return -EBUSY; | ||
206 | |||
207 | twi_base = ioremap(res->start, res->end - res->start + 1); | ||
208 | if (!twi_base) { | ||
209 | rc = -ENOMEM; | ||
210 | goto fail0; | ||
211 | } | ||
212 | |||
213 | twi_clk = clk_get(NULL, "twi_clk"); | ||
214 | if (IS_ERR(twi_clk)) { | ||
215 | dev_err(&pdev->dev, "no clock defined\n"); | ||
216 | rc = -ENODEV; | ||
217 | goto fail1; | ||
218 | } | ||
219 | |||
220 | adapter = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL); | ||
221 | if (adapter == NULL) { | ||
222 | dev_err(&pdev->dev, "can't allocate inteface!\n"); | ||
223 | rc = -ENOMEM; | ||
224 | goto fail2; | ||
225 | } | ||
226 | sprintf(adapter->name, "AT91"); | ||
227 | adapter->algo = &at91_algorithm; | ||
228 | adapter->class = I2C_CLASS_HWMON; | ||
229 | adapter->dev.parent = &pdev->dev; | ||
230 | |||
231 | platform_set_drvdata(pdev, adapter); | ||
232 | |||
233 | clk_enable(twi_clk); /* enable peripheral clock */ | ||
234 | at91_twi_hwinit(); /* initialize TWI controller */ | ||
235 | |||
236 | rc = i2c_add_adapter(adapter); | ||
237 | if (rc) { | ||
238 | dev_err(&pdev->dev, "Adapter %s registration failed\n", | ||
239 | adapter->name); | ||
240 | goto fail3; | ||
241 | } | ||
242 | |||
243 | dev_info(&pdev->dev, "AT91 i2c bus driver.\n"); | ||
244 | return 0; | ||
245 | |||
246 | fail3: | ||
247 | platform_set_drvdata(pdev, NULL); | ||
248 | kfree(adapter); | ||
249 | clk_disable(twi_clk); | ||
250 | fail2: | ||
251 | clk_put(twi_clk); | ||
252 | fail1: | ||
253 | iounmap(twi_base); | ||
254 | fail0: | ||
255 | release_mem_region(res->start, res->end - res->start + 1); | ||
256 | |||
257 | return rc; | ||
258 | } | ||
259 | |||
260 | static int __devexit at91_i2c_remove(struct platform_device *pdev) | ||
261 | { | ||
262 | struct i2c_adapter *adapter = platform_get_drvdata(pdev); | ||
263 | struct resource *res; | ||
264 | int rc; | ||
265 | |||
266 | rc = i2c_del_adapter(adapter); | ||
267 | platform_set_drvdata(pdev, NULL); | ||
268 | |||
269 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
270 | iounmap(twi_base); | ||
271 | release_mem_region(res->start, res->end - res->start + 1); | ||
272 | |||
273 | clk_disable(twi_clk); /* disable peripheral clock */ | ||
274 | clk_put(twi_clk); | ||
275 | |||
276 | return rc; | ||
277 | } | ||
278 | |||
279 | #ifdef CONFIG_PM | ||
280 | |||
281 | /* NOTE: could save a few mA by keeping clock off outside of at91_xfer... */ | ||
282 | |||
283 | static int at91_i2c_suspend(struct platform_device *pdev, pm_message_t mesg) | ||
284 | { | ||
285 | clk_disable(twi_clk); | ||
286 | return 0; | ||
287 | } | ||
288 | |||
289 | static int at91_i2c_resume(struct platform_device *pdev) | ||
290 | { | ||
291 | return clk_enable(twi_clk); | ||
292 | } | ||
293 | |||
294 | #else | ||
295 | #define at91_i2c_suspend NULL | ||
296 | #define at91_i2c_resume NULL | ||
297 | #endif | ||
298 | |||
299 | static struct platform_driver at91_i2c_driver = { | ||
300 | .probe = at91_i2c_probe, | ||
301 | .remove = __devexit_p(at91_i2c_remove), | ||
302 | .suspend = at91_i2c_suspend, | ||
303 | .resume = at91_i2c_resume, | ||
304 | .driver = { | ||
305 | .name = "at91_i2c", | ||
306 | .owner = THIS_MODULE, | ||
307 | }, | ||
308 | }; | ||
309 | |||
310 | static int __init at91_i2c_init(void) | ||
311 | { | ||
312 | return platform_driver_register(&at91_i2c_driver); | ||
313 | } | ||
314 | |||
315 | static void __exit at91_i2c_exit(void) | ||
316 | { | ||
317 | platform_driver_unregister(&at91_i2c_driver); | ||
318 | } | ||
319 | |||
320 | module_init(at91_i2c_init); | ||
321 | module_exit(at91_i2c_exit); | ||
322 | |||
323 | MODULE_AUTHOR("Rick Bronson"); | ||
324 | MODULE_DESCRIPTION("I2C (TWI) driver for Atmel AT91"); | ||
325 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c index a591fe685f06..834967464814 100644 --- a/drivers/i2c/busses/i2c-elektor.c +++ b/drivers/i2c/busses/i2c-elektor.c | |||
@@ -293,7 +293,7 @@ static int __init i2c_pcfisa_init(void) | |||
293 | 293 | ||
294 | static void i2c_pcfisa_exit(void) | 294 | static void i2c_pcfisa_exit(void) |
295 | { | 295 | { |
296 | i2c_pcf_del_bus(&pcf_isa_ops); | 296 | i2c_del_adapter(&pcf_isa_ops); |
297 | 297 | ||
298 | if (irq > 0) { | 298 | if (irq > 0) { |
299 | disable_irq(irq); | 299 | disable_irq(irq); |
diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c index 457d48a0ab9d..9832f773651d 100644 --- a/drivers/i2c/busses/i2c-hydra.c +++ b/drivers/i2c/busses/i2c-hydra.c | |||
@@ -146,7 +146,7 @@ static int __devinit hydra_probe(struct pci_dev *dev, | |||
146 | static void __devexit hydra_remove(struct pci_dev *dev) | 146 | static void __devexit hydra_remove(struct pci_dev *dev) |
147 | { | 147 | { |
148 | pdregw(hydra_bit_data.data, 0); /* clear SCLK_OE and SDAT_OE */ | 148 | pdregw(hydra_bit_data.data, 0); /* clear SCLK_OE and SDAT_OE */ |
149 | i2c_bit_del_bus(&hydra_adap); | 149 | i2c_del_adapter(&hydra_adap); |
150 | iounmap(hydra_bit_data.data); | 150 | iounmap(hydra_bit_data.data); |
151 | release_mem_region(pci_resource_start(dev, 0)+ | 151 | release_mem_region(pci_resource_start(dev, 0)+ |
152 | offsetof(struct Hydra, CachePD), 4); | 152 | offsetof(struct Hydra, CachePD), 4); |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index c7be2fdbd86b..ae625b854470 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -470,12 +470,20 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id | |||
470 | int err; | 470 | int err; |
471 | 471 | ||
472 | I801_dev = dev; | 472 | I801_dev = dev; |
473 | if ((dev->device == PCI_DEVICE_ID_INTEL_82801DB_3) || | 473 | switch (dev->device) { |
474 | (dev->device == PCI_DEVICE_ID_INTEL_82801EB_3) || | 474 | case PCI_DEVICE_ID_INTEL_82801DB_3: |
475 | (dev->device == PCI_DEVICE_ID_INTEL_ESB_4)) | 475 | case PCI_DEVICE_ID_INTEL_82801EB_3: |
476 | case PCI_DEVICE_ID_INTEL_ESB_4: | ||
477 | case PCI_DEVICE_ID_INTEL_ICH6_16: | ||
478 | case PCI_DEVICE_ID_INTEL_ICH7_17: | ||
479 | case PCI_DEVICE_ID_INTEL_ESB2_17: | ||
480 | case PCI_DEVICE_ID_INTEL_ICH8_5: | ||
481 | case PCI_DEVICE_ID_INTEL_ICH9_6: | ||
476 | isich4 = 1; | 482 | isich4 = 1; |
477 | else | 483 | break; |
484 | default: | ||
478 | isich4 = 0; | 485 | isich4 = 0; |
486 | } | ||
479 | 487 | ||
480 | err = pci_enable_device(dev); | 488 | err = pci_enable_device(dev); |
481 | if (err) { | 489 | if (err) { |
diff --git a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c index b66fb6bb1870..10c98bc88aa6 100644 --- a/drivers/i2c/busses/i2c-i810.c +++ b/drivers/i2c/busses/i2c-i810.c | |||
@@ -219,14 +219,14 @@ static int __devinit i810_probe(struct pci_dev *dev, const struct pci_device_id | |||
219 | return retval; | 219 | return retval; |
220 | retval = i2c_bit_add_bus(&i810_ddc_adapter); | 220 | retval = i2c_bit_add_bus(&i810_ddc_adapter); |
221 | if (retval) | 221 | if (retval) |
222 | i2c_bit_del_bus(&i810_i2c_adapter); | 222 | i2c_del_adapter(&i810_i2c_adapter); |
223 | return retval; | 223 | return retval; |
224 | } | 224 | } |
225 | 225 | ||
226 | static void __devexit i810_remove(struct pci_dev *dev) | 226 | static void __devexit i810_remove(struct pci_dev *dev) |
227 | { | 227 | { |
228 | i2c_bit_del_bus(&i810_ddc_adapter); | 228 | i2c_del_adapter(&i810_ddc_adapter); |
229 | i2c_bit_del_bus(&i810_i2c_adapter); | 229 | i2c_del_adapter(&i810_i2c_adapter); |
230 | iounmap(ioaddr); | 230 | iounmap(ioaddr); |
231 | } | 231 | } |
232 | 232 | ||
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index 781a99c1647a..1898e9987021 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c | |||
@@ -680,6 +680,12 @@ static int __devinit iic_probe(struct ocp_device *ocp){ | |||
680 | dev->idx = ocp->def->index; | 680 | dev->idx = ocp->def->index; |
681 | ocp_set_drvdata(ocp, dev); | 681 | ocp_set_drvdata(ocp, dev); |
682 | 682 | ||
683 | if (!request_mem_region(ocp->def->paddr, sizeof(struct iic_regs), | ||
684 | "ibm_iic")) { | ||
685 | ret = -EBUSY; | ||
686 | goto fail1; | ||
687 | } | ||
688 | |||
683 | if (!(dev->vaddr = ioremap(ocp->def->paddr, sizeof(struct iic_regs)))){ | 689 | if (!(dev->vaddr = ioremap(ocp->def->paddr, sizeof(struct iic_regs)))){ |
684 | printk(KERN_CRIT "ibm-iic%d: failed to ioremap device registers\n", | 690 | printk(KERN_CRIT "ibm-iic%d: failed to ioremap device registers\n", |
685 | dev->idx); | 691 | dev->idx); |
@@ -750,6 +756,8 @@ fail: | |||
750 | 756 | ||
751 | iounmap(dev->vaddr); | 757 | iounmap(dev->vaddr); |
752 | fail2: | 758 | fail2: |
759 | release_mem_region(ocp->def->paddr, sizeof(struct iic_regs)); | ||
760 | fail1: | ||
753 | ocp_set_drvdata(ocp, NULL); | 761 | ocp_set_drvdata(ocp, NULL); |
754 | kfree(dev); | 762 | kfree(dev); |
755 | return ret; | 763 | return ret; |
@@ -777,6 +785,7 @@ static void __devexit iic_remove(struct ocp_device *ocp) | |||
777 | free_irq(dev->irq, dev); | 785 | free_irq(dev->irq, dev); |
778 | } | 786 | } |
779 | iounmap(dev->vaddr); | 787 | iounmap(dev->vaddr); |
788 | release_mem_region(ocp->def->paddr, sizeof(struct iic_regs)); | ||
780 | kfree(dev); | 789 | kfree(dev); |
781 | } | 790 | } |
782 | } | 791 | } |
diff --git a/drivers/i2c/busses/i2c-ite.c b/drivers/i2c/busses/i2c-ite.c deleted file mode 100644 index f7d71869b3b9..000000000000 --- a/drivers/i2c/busses/i2c-ite.c +++ /dev/null | |||
@@ -1,278 +0,0 @@ | |||
1 | /* | ||
2 | ------------------------------------------------------------------------- | ||
3 | i2c-adap-ite.c i2c-hw access for the IIC peripheral on the ITE MIPS system | ||
4 | ------------------------------------------------------------------------- | ||
5 | Hai-Pao Fan, MontaVista Software, Inc. | ||
6 | hpfan@mvista.com or source@mvista.com | ||
7 | |||
8 | Copyright 2001 MontaVista Software Inc. | ||
9 | |||
10 | ---------------------------------------------------------------------------- | ||
11 | This file was highly leveraged from i2c-elektor.c, which was created | ||
12 | by Simon G. Vogl and Hans Berglund: | ||
13 | |||
14 | |||
15 | Copyright (C) 1995-97 Simon G. Vogl | ||
16 | 1998-99 Hans Berglund | ||
17 | |||
18 | This program is free software; you can redistribute it and/or modify | ||
19 | it under the terms of the GNU General Public License as published by | ||
20 | the Free Software Foundation; either version 2 of the License, or | ||
21 | (at your option) any later version. | ||
22 | |||
23 | This program is distributed in the hope that it will be useful, | ||
24 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
25 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
26 | GNU General Public License for more details. | ||
27 | |||
28 | You should have received a copy of the GNU General Public License | ||
29 | along with this program; if not, write to the Free Software | ||
30 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
31 | /* ------------------------------------------------------------------------- */ | ||
32 | |||
33 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even | ||
34 | Frodo Looijaard <frodol@dds.nl> */ | ||
35 | |||
36 | #include <linux/kernel.h> | ||
37 | #include <linux/ioport.h> | ||
38 | #include <linux/module.h> | ||
39 | #include <linux/delay.h> | ||
40 | #include <linux/slab.h> | ||
41 | #include <linux/init.h> | ||
42 | #include <linux/wait.h> | ||
43 | #include <asm/irq.h> | ||
44 | #include <asm/io.h> | ||
45 | |||
46 | #include <linux/i2c.h> | ||
47 | #include <linux/i2c-algo-ite.h> | ||
48 | #include <linux/i2c-adap-ite.h> | ||
49 | #include "../i2c-ite.h" | ||
50 | |||
51 | #define DEFAULT_BASE 0x14014030 | ||
52 | #define ITE_IIC_IO_SIZE 0x40 | ||
53 | #define DEFAULT_IRQ 0 | ||
54 | #define DEFAULT_CLOCK 0x1b0e /* default 16MHz/(27+14) = 400KHz */ | ||
55 | #define DEFAULT_OWN 0x55 | ||
56 | |||
57 | static int base; | ||
58 | static int irq; | ||
59 | static int clock; | ||
60 | static int own; | ||
61 | |||
62 | static struct iic_ite gpi; | ||
63 | static wait_queue_head_t iic_wait; | ||
64 | static int iic_pending; | ||
65 | static spinlock_t lock; | ||
66 | |||
67 | /* ----- local functions ---------------------------------------------- */ | ||
68 | |||
69 | static void iic_ite_setiic(void *data, int ctl, short val) | ||
70 | { | ||
71 | unsigned long j = jiffies + 10; | ||
72 | |||
73 | pr_debug(" Write 0x%02x to 0x%x\n",(unsigned short)val, ctl&0xff); | ||
74 | #ifdef DEBUG | ||
75 | while (time_before(jiffies, j)) | ||
76 | schedule(); | ||
77 | #endif | ||
78 | outw(val,ctl); | ||
79 | } | ||
80 | |||
81 | static short iic_ite_getiic(void *data, int ctl) | ||
82 | { | ||
83 | short val; | ||
84 | |||
85 | val = inw(ctl); | ||
86 | pr_debug("Read 0x%02x from 0x%x\n",(unsigned short)val, ctl&0xff); | ||
87 | return (val); | ||
88 | } | ||
89 | |||
90 | /* Return our slave address. This is the address | ||
91 | * put on the I2C bus when another master on the bus wants to address us | ||
92 | * as a slave | ||
93 | */ | ||
94 | static int iic_ite_getown(void *data) | ||
95 | { | ||
96 | return (gpi.iic_own); | ||
97 | } | ||
98 | |||
99 | |||
100 | static int iic_ite_getclock(void *data) | ||
101 | { | ||
102 | return (gpi.iic_clock); | ||
103 | } | ||
104 | |||
105 | |||
106 | /* Put this process to sleep. We will wake up when the | ||
107 | * IIC controller interrupts. | ||
108 | */ | ||
109 | static void iic_ite_waitforpin(void) { | ||
110 | DEFINE_WAIT(wait); | ||
111 | int timeout = 2; | ||
112 | unsigned long flags; | ||
113 | |||
114 | /* If interrupts are enabled (which they are), then put the process to | ||
115 | * sleep. This process will be awakened by two events -- either the | ||
116 | * the IIC peripheral interrupts or the timeout expires. | ||
117 | * If interrupts are not enabled then delay for a reasonable amount | ||
118 | * of time and return. | ||
119 | */ | ||
120 | if (gpi.iic_irq > 0) { | ||
121 | spin_lock_irqsave(&lock, flags); | ||
122 | if (iic_pending == 0) { | ||
123 | spin_unlock_irqrestore(&lock, flags); | ||
124 | prepare_to_wait(&iic_wait, &wait, TASK_INTERRUPTIBLE); | ||
125 | if (schedule_timeout(timeout*HZ)) { | ||
126 | spin_lock_irqsave(&lock, flags); | ||
127 | if (iic_pending == 1) { | ||
128 | iic_pending = 0; | ||
129 | } | ||
130 | spin_unlock_irqrestore(&lock, flags); | ||
131 | } | ||
132 | finish_wait(&iic_wait, &wait); | ||
133 | } else { | ||
134 | iic_pending = 0; | ||
135 | spin_unlock_irqrestore(&lock, flags); | ||
136 | } | ||
137 | } else { | ||
138 | udelay(100); | ||
139 | } | ||
140 | } | ||
141 | |||
142 | |||
143 | static irqreturn_t iic_ite_handler(int this_irq, void *dev_id) | ||
144 | { | ||
145 | spin_lock(&lock); | ||
146 | iic_pending = 1; | ||
147 | spin_unlock(&lock); | ||
148 | |||
149 | wake_up_interruptible(&iic_wait); | ||
150 | |||
151 | return IRQ_HANDLED; | ||
152 | } | ||
153 | |||
154 | |||
155 | /* Lock the region of memory where I/O registers exist. Request our | ||
156 | * interrupt line and register its associated handler. | ||
157 | */ | ||
158 | static int iic_hw_resrc_init(void) | ||
159 | { | ||
160 | if (!request_region(gpi.iic_base, ITE_IIC_IO_SIZE, "i2c")) | ||
161 | return -ENODEV; | ||
162 | |||
163 | if (gpi.iic_irq <= 0) | ||
164 | return 0; | ||
165 | |||
166 | if (request_irq(gpi.iic_irq, iic_ite_handler, 0, "ITE IIC", 0) < 0) | ||
167 | gpi.iic_irq = 0; | ||
168 | else | ||
169 | enable_irq(gpi.iic_irq); | ||
170 | |||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | |||
175 | static void iic_ite_release(void) | ||
176 | { | ||
177 | if (gpi.iic_irq > 0) { | ||
178 | disable_irq(gpi.iic_irq); | ||
179 | free_irq(gpi.iic_irq, 0); | ||
180 | } | ||
181 | release_region(gpi.iic_base , 2); | ||
182 | } | ||
183 | |||
184 | /* ------------------------------------------------------------------------ | ||
185 | * Encapsulate the above functions in the correct operations structure. | ||
186 | * This is only done when more than one hardware adapter is supported. | ||
187 | */ | ||
188 | static struct i2c_algo_iic_data iic_ite_data = { | ||
189 | NULL, | ||
190 | iic_ite_setiic, | ||
191 | iic_ite_getiic, | ||
192 | iic_ite_getown, | ||
193 | iic_ite_getclock, | ||
194 | iic_ite_waitforpin, | ||
195 | 80, 80, 100, /* waits, timeout */ | ||
196 | }; | ||
197 | |||
198 | static struct i2c_adapter iic_ite_ops = { | ||
199 | .owner = THIS_MODULE, | ||
200 | .id = I2C_HW_I_IIC, | ||
201 | .algo_data = &iic_ite_data, | ||
202 | .name = "ITE IIC adapter", | ||
203 | }; | ||
204 | |||
205 | /* Called when the module is loaded. This function starts the | ||
206 | * cascade of calls up through the hierarchy of i2c modules (i.e. up to the | ||
207 | * algorithm layer and into to the core layer) | ||
208 | */ | ||
209 | static int __init iic_ite_init(void) | ||
210 | { | ||
211 | |||
212 | struct iic_ite *piic = &gpi; | ||
213 | |||
214 | printk(KERN_INFO "Initialize ITE IIC adapter module\n"); | ||
215 | if (base == 0) | ||
216 | piic->iic_base = DEFAULT_BASE; | ||
217 | else | ||
218 | piic->iic_base = base; | ||
219 | |||
220 | if (irq == 0) | ||
221 | piic->iic_irq = DEFAULT_IRQ; | ||
222 | else | ||
223 | piic->iic_irq = irq; | ||
224 | |||
225 | if (clock == 0) | ||
226 | piic->iic_clock = DEFAULT_CLOCK; | ||
227 | else | ||
228 | piic->iic_clock = clock; | ||
229 | |||
230 | if (own == 0) | ||
231 | piic->iic_own = DEFAULT_OWN; | ||
232 | else | ||
233 | piic->iic_own = own; | ||
234 | |||
235 | iic_ite_data.data = (void *)piic; | ||
236 | init_waitqueue_head(&iic_wait); | ||
237 | spin_lock_init(&lock); | ||
238 | if (iic_hw_resrc_init() == 0) { | ||
239 | if (i2c_iic_add_bus(&iic_ite_ops) < 0) | ||
240 | return -ENODEV; | ||
241 | } else { | ||
242 | return -ENODEV; | ||
243 | } | ||
244 | printk(KERN_INFO " found device at %#x irq %d.\n", | ||
245 | piic->iic_base, piic->iic_irq); | ||
246 | return 0; | ||
247 | } | ||
248 | |||
249 | |||
250 | static void iic_ite_exit(void) | ||
251 | { | ||
252 | i2c_iic_del_bus(&iic_ite_ops); | ||
253 | iic_ite_release(); | ||
254 | } | ||
255 | |||
256 | /* If modules is NOT defined when this file is compiled, then the MODULE_* | ||
257 | * macros will resolve to nothing | ||
258 | */ | ||
259 | MODULE_AUTHOR("MontaVista Software <www.mvista.com>"); | ||
260 | MODULE_DESCRIPTION("I2C-Bus adapter routines for ITE IIC bus adapter"); | ||
261 | MODULE_LICENSE("GPL"); | ||
262 | |||
263 | module_param(base, int, 0); | ||
264 | module_param(irq, int, 0); | ||
265 | module_param(clock, int, 0); | ||
266 | module_param(own, int, 0); | ||
267 | |||
268 | |||
269 | /* Called when module is loaded or when kernel is initialized. | ||
270 | * If MODULES is defined when this file is compiled, then this function will | ||
271 | * resolve to init_module (the function called when insmod is invoked for a | ||
272 | * module). Otherwise, this function is called early in the boot, when the | ||
273 | * kernel is intialized. Check out /include/init.h to see how this works. | ||
274 | */ | ||
275 | module_init(iic_ite_init); | ||
276 | |||
277 | /* Resolves to module_cleanup when MODULES is defined. */ | ||
278 | module_exit(iic_ite_exit); | ||
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c index dd3f4cd3aa68..efa3ecc5522a 100644 --- a/drivers/i2c/busses/i2c-ixp2000.c +++ b/drivers/i2c/busses/i2c-ixp2000.c | |||
@@ -90,7 +90,7 @@ static int ixp2000_i2c_remove(struct platform_device *plat_dev) | |||
90 | 90 | ||
91 | platform_set_drvdata(plat_dev, NULL); | 91 | platform_set_drvdata(plat_dev, NULL); |
92 | 92 | ||
93 | i2c_bit_del_bus(&drv_data->adapter); | 93 | i2c_del_adapter(&drv_data->adapter); |
94 | 94 | ||
95 | kfree(drv_data); | 95 | kfree(drv_data); |
96 | 96 | ||
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c index 68fe863f9d54..08e89b83984a 100644 --- a/drivers/i2c/busses/i2c-ixp4xx.c +++ b/drivers/i2c/busses/i2c-ixp4xx.c | |||
@@ -91,7 +91,7 @@ static int ixp4xx_i2c_remove(struct platform_device *plat_dev) | |||
91 | 91 | ||
92 | platform_set_drvdata(plat_dev, NULL); | 92 | platform_set_drvdata(plat_dev, NULL); |
93 | 93 | ||
94 | i2c_bit_del_bus(&drv_data->adapter); | 94 | i2c_del_adapter(&drv_data->adapter); |
95 | 95 | ||
96 | kfree(drv_data); | 96 | kfree(drv_data); |
97 | 97 | ||
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index e0292e414ab2..ad37c10e7fec 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c | |||
@@ -35,7 +35,7 @@ | |||
35 | nForce4 MCP55 0368 | 35 | nForce4 MCP55 0368 |
36 | 36 | ||
37 | This driver supports the 2 SMBuses that are included in the MCP of the | 37 | This driver supports the 2 SMBuses that are included in the MCP of the |
38 | nForce2/3/4 chipsets. | 38 | nForce2/3/4/5xx chipsets. |
39 | */ | 39 | */ |
40 | 40 | ||
41 | /* Note: we assume there can only be one nForce2, with two SMBus interfaces */ | 41 | /* Note: we assume there can only be one nForce2, with two SMBus interfaces */ |
@@ -52,8 +52,8 @@ | |||
52 | #include <asm/io.h> | 52 | #include <asm/io.h> |
53 | 53 | ||
54 | MODULE_LICENSE("GPL"); | 54 | MODULE_LICENSE("GPL"); |
55 | MODULE_AUTHOR ("Hans-Frieder Vogt <hfvogt@arcor.de>"); | 55 | MODULE_AUTHOR ("Hans-Frieder Vogt <hfvogt@gmx.net>"); |
56 | MODULE_DESCRIPTION("nForce2 SMBus driver"); | 56 | MODULE_DESCRIPTION("nForce2/3/4/5xx SMBus driver"); |
57 | 57 | ||
58 | 58 | ||
59 | struct nforce2_smbus { | 59 | struct nforce2_smbus { |
@@ -80,9 +80,6 @@ struct nforce2_smbus { | |||
80 | #define NVIDIA_SMB_ADDR (smbus->base + 0x02) /* address */ | 80 | #define NVIDIA_SMB_ADDR (smbus->base + 0x02) /* address */ |
81 | #define NVIDIA_SMB_CMD (smbus->base + 0x03) /* command */ | 81 | #define NVIDIA_SMB_CMD (smbus->base + 0x03) /* command */ |
82 | #define NVIDIA_SMB_DATA (smbus->base + 0x04) /* 32 data registers */ | 82 | #define NVIDIA_SMB_DATA (smbus->base + 0x04) /* 32 data registers */ |
83 | #define NVIDIA_SMB_BCNT (smbus->base + 0x24) /* number of data bytes */ | ||
84 | #define NVIDIA_SMB_ALRM_A (smbus->base + 0x25) /* alarm address */ | ||
85 | #define NVIDIA_SMB_ALRM_D (smbus->base + 0x26) /* 2 bytes alarm data */ | ||
86 | 83 | ||
87 | #define NVIDIA_SMB_STS_DONE 0x80 | 84 | #define NVIDIA_SMB_STS_DONE 0x80 |
88 | #define NVIDIA_SMB_STS_ALRM 0x40 | 85 | #define NVIDIA_SMB_STS_ALRM 0x40 |
@@ -95,40 +92,17 @@ struct nforce2_smbus { | |||
95 | #define NVIDIA_SMB_PRTCL_BYTE 0x04 | 92 | #define NVIDIA_SMB_PRTCL_BYTE 0x04 |
96 | #define NVIDIA_SMB_PRTCL_BYTE_DATA 0x06 | 93 | #define NVIDIA_SMB_PRTCL_BYTE_DATA 0x06 |
97 | #define NVIDIA_SMB_PRTCL_WORD_DATA 0x08 | 94 | #define NVIDIA_SMB_PRTCL_WORD_DATA 0x08 |
98 | #define NVIDIA_SMB_PRTCL_BLOCK_DATA 0x0a | ||
99 | #define NVIDIA_SMB_PRTCL_PROC_CALL 0x0c | ||
100 | #define NVIDIA_SMB_PRTCL_BLOCK_PROC_CALL 0x0d | ||
101 | #define NVIDIA_SMB_PRTCL_I2C_BLOCK_DATA 0x4a | ||
102 | #define NVIDIA_SMB_PRTCL_PEC 0x80 | 95 | #define NVIDIA_SMB_PRTCL_PEC 0x80 |
103 | 96 | ||
104 | static struct pci_driver nforce2_driver; | 97 | static struct pci_driver nforce2_driver; |
105 | 98 | ||
106 | static s32 nforce2_access(struct i2c_adapter *adap, u16 addr, | 99 | /* Return -1 on error */ |
107 | unsigned short flags, char read_write, | ||
108 | u8 command, int size, union i2c_smbus_data *data); | ||
109 | static u32 nforce2_func(struct i2c_adapter *adapter); | ||
110 | |||
111 | |||
112 | static const struct i2c_algorithm smbus_algorithm = { | ||
113 | .smbus_xfer = nforce2_access, | ||
114 | .functionality = nforce2_func, | ||
115 | }; | ||
116 | |||
117 | static struct i2c_adapter nforce2_adapter = { | ||
118 | .owner = THIS_MODULE, | ||
119 | .class = I2C_CLASS_HWMON, | ||
120 | .algo = &smbus_algorithm, | ||
121 | }; | ||
122 | |||
123 | /* Return -1 on error. See smbus.h for more information */ | ||
124 | static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, | 100 | static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, |
125 | unsigned short flags, char read_write, | 101 | unsigned short flags, char read_write, |
126 | u8 command, int size, union i2c_smbus_data * data) | 102 | u8 command, int size, union i2c_smbus_data * data) |
127 | { | 103 | { |
128 | struct nforce2_smbus *smbus = adap->algo_data; | 104 | struct nforce2_smbus *smbus = adap->algo_data; |
129 | unsigned char protocol, pec, temp; | 105 | unsigned char protocol, pec, temp; |
130 | unsigned char len = 0; /* to keep the compiler quiet */ | ||
131 | int i; | ||
132 | 106 | ||
133 | protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ : | 107 | protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ : |
134 | NVIDIA_SMB_PRTCL_WRITE; | 108 | NVIDIA_SMB_PRTCL_WRITE; |
@@ -163,35 +137,6 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, | |||
163 | protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec; | 137 | protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec; |
164 | break; | 138 | break; |
165 | 139 | ||
166 | case I2C_SMBUS_BLOCK_DATA: | ||
167 | outb_p(command, NVIDIA_SMB_CMD); | ||
168 | if (read_write == I2C_SMBUS_WRITE) { | ||
169 | len = min_t(u8, data->block[0], 32); | ||
170 | outb_p(len, NVIDIA_SMB_BCNT); | ||
171 | for (i = 0; i < len; i++) | ||
172 | outb_p(data->block[i + 1], NVIDIA_SMB_DATA+i); | ||
173 | } | ||
174 | protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec; | ||
175 | break; | ||
176 | |||
177 | case I2C_SMBUS_I2C_BLOCK_DATA: | ||
178 | len = min_t(u8, data->block[0], 32); | ||
179 | outb_p(command, NVIDIA_SMB_CMD); | ||
180 | outb_p(len, NVIDIA_SMB_BCNT); | ||
181 | if (read_write == I2C_SMBUS_WRITE) | ||
182 | for (i = 0; i < len; i++) | ||
183 | outb_p(data->block[i + 1], NVIDIA_SMB_DATA+i); | ||
184 | protocol |= NVIDIA_SMB_PRTCL_I2C_BLOCK_DATA; | ||
185 | break; | ||
186 | |||
187 | case I2C_SMBUS_PROC_CALL: | ||
188 | dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); | ||
189 | return -1; | ||
190 | |||
191 | case I2C_SMBUS_BLOCK_PROC_CALL: | ||
192 | dev_err(&adap->dev, "I2C_SMBUS_BLOCK_PROC_CALL not supported!\n"); | ||
193 | return -1; | ||
194 | |||
195 | default: | 140 | default: |
196 | dev_err(&adap->dev, "Unsupported transaction %d\n", size); | 141 | dev_err(&adap->dev, "Unsupported transaction %d\n", size); |
197 | return -1; | 142 | return -1; |
@@ -227,19 +172,8 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, | |||
227 | break; | 172 | break; |
228 | 173 | ||
229 | case I2C_SMBUS_WORD_DATA: | 174 | case I2C_SMBUS_WORD_DATA: |
230 | /* case I2C_SMBUS_PROC_CALL: not supported */ | ||
231 | data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA+1) << 8); | 175 | data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA+1) << 8); |
232 | break; | 176 | break; |
233 | |||
234 | case I2C_SMBUS_BLOCK_DATA: | ||
235 | /* case I2C_SMBUS_BLOCK_PROC_CALL: not supported */ | ||
236 | len = inb_p(NVIDIA_SMB_BCNT); | ||
237 | len = min_t(u8, len, 32); | ||
238 | case I2C_SMBUS_I2C_BLOCK_DATA: | ||
239 | for (i = 0; i < len; i++) | ||
240 | data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i); | ||
241 | data->block[0] = len; | ||
242 | break; | ||
243 | } | 177 | } |
244 | 178 | ||
245 | return 0; | 179 | return 0; |
@@ -250,10 +184,14 @@ static u32 nforce2_func(struct i2c_adapter *adapter) | |||
250 | { | 184 | { |
251 | /* other functionality might be possible, but is not tested */ | 185 | /* other functionality might be possible, but is not tested */ |
252 | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | | 186 | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | |
253 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA /* | | 187 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA; |
254 | I2C_FUNC_SMBUS_BLOCK_DATA */; | ||
255 | } | 188 | } |
256 | 189 | ||
190 | static struct i2c_algorithm smbus_algorithm = { | ||
191 | .smbus_xfer = nforce2_access, | ||
192 | .functionality = nforce2_func, | ||
193 | }; | ||
194 | |||
257 | 195 | ||
258 | static struct pci_device_id nforce2_ids[] = { | 196 | static struct pci_device_id nforce2_ids[] = { |
259 | { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS) }, | 197 | { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS) }, |
@@ -267,7 +205,6 @@ static struct pci_device_id nforce2_ids[] = { | |||
267 | { 0 } | 205 | { 0 } |
268 | }; | 206 | }; |
269 | 207 | ||
270 | |||
271 | MODULE_DEVICE_TABLE (pci, nforce2_ids); | 208 | MODULE_DEVICE_TABLE (pci, nforce2_ids); |
272 | 209 | ||
273 | 210 | ||
@@ -291,7 +228,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar, | |||
291 | } | 228 | } |
292 | 229 | ||
293 | smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK; | 230 | smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK; |
294 | smbus->size = 8; | 231 | smbus->size = 64; |
295 | } | 232 | } |
296 | smbus->dev = dev; | 233 | smbus->dev = dev; |
297 | 234 | ||
@@ -300,7 +237,9 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar, | |||
300 | smbus->base, smbus->base+smbus->size-1, name); | 237 | smbus->base, smbus->base+smbus->size-1, name); |
301 | return -1; | 238 | return -1; |
302 | } | 239 | } |
303 | smbus->adapter = nforce2_adapter; | 240 | smbus->adapter.owner = THIS_MODULE; |
241 | smbus->adapter.class = I2C_CLASS_HWMON; | ||
242 | smbus->adapter.algo = &smbus_algorithm; | ||
304 | smbus->adapter.algo_data = smbus; | 243 | smbus->adapter.algo_data = smbus; |
305 | smbus->adapter.dev.parent = &dev->dev; | 244 | smbus->adapter.dev.parent = &dev->dev; |
306 | snprintf(smbus->adapter.name, I2C_NAME_SIZE, | 245 | snprintf(smbus->adapter.name, I2C_NAME_SIZE, |
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index dec04da0455c..bcd8367cede1 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c | |||
@@ -231,8 +231,8 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
231 | * 13 2 1 | 231 | * 13 2 1 |
232 | * 19.2 2 1 | 232 | * 19.2 2 1 |
233 | */ | 233 | */ |
234 | if (fclk_rate > 16000000) | 234 | if (fclk_rate > 12000000) |
235 | psc = (fclk_rate + 8000000) / 12000000; | 235 | psc = fclk_rate / 12000000; |
236 | } | 236 | } |
237 | 237 | ||
238 | /* Setup clock prescaler to obtain approx 12MHz I2C module clock: */ | 238 | /* Setup clock prescaler to obtain approx 12MHz I2C module clock: */ |
diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c index 5eb2bd294fd9..4bc42810b9aa 100644 --- a/drivers/i2c/busses/i2c-parport-light.c +++ b/drivers/i2c/busses/i2c-parport-light.c | |||
@@ -163,7 +163,7 @@ static void __exit i2c_parport_exit(void) | |||
163 | if (adapter_parm[type].init.val) | 163 | if (adapter_parm[type].init.val) |
164 | line_set(0, &adapter_parm[type].init); | 164 | line_set(0, &adapter_parm[type].init); |
165 | 165 | ||
166 | i2c_bit_del_bus(&parport_adapter); | 166 | i2c_del_adapter(&parport_adapter); |
167 | release_region(base, 3); | 167 | release_region(base, 3); |
168 | } | 168 | } |
169 | 169 | ||
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index 48a829431c7b..66696a40c7b5 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c | |||
@@ -218,7 +218,7 @@ static void i2c_parport_detach (struct parport *port) | |||
218 | if (adapter_parm[type].init.val) | 218 | if (adapter_parm[type].init.val) |
219 | line_set(port, 0, &adapter_parm[type].init); | 219 | line_set(port, 0, &adapter_parm[type].init); |
220 | 220 | ||
221 | i2c_bit_del_bus(&adapter->adapter); | 221 | i2c_del_adapter(&adapter->adapter); |
222 | parport_unregister_device(adapter->pdev); | 222 | parport_unregister_device(adapter->pdev); |
223 | if (prev) | 223 | if (prev) |
224 | prev->next = adapter->next; | 224 | prev->next = adapter->next; |
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c index 407840b6a260..cc6536a19eca 100644 --- a/drivers/i2c/busses/i2c-pca-isa.c +++ b/drivers/i2c/busses/i2c-pca-isa.c | |||
@@ -156,7 +156,7 @@ static int __init pca_isa_init(void) | |||
156 | 156 | ||
157 | static void pca_isa_exit(void) | 157 | static void pca_isa_exit(void) |
158 | { | 158 | { |
159 | i2c_pca_del_bus(&pca_isa_ops); | 159 | i2c_del_adapter(&pca_isa_ops); |
160 | 160 | ||
161 | if (irq > 0) { | 161 | if (irq > 0) { |
162 | disable_irq(irq); | 162 | disable_irq(irq); |
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c new file mode 100644 index 000000000000..de0bca77e926 --- /dev/null +++ b/drivers/i2c/busses/i2c-pnx.c | |||
@@ -0,0 +1,708 @@ | |||
1 | /* | ||
2 | * Provides I2C support for Philips PNX010x/PNX4008 boards. | ||
3 | * | ||
4 | * Authors: Dennis Kovalev <dkovalev@ru.mvista.com> | ||
5 | * Vitaly Wool <vwool@ru.mvista.com> | ||
6 | * | ||
7 | * 2004-2006 (c) MontaVista Software, Inc. This file is licensed under | ||
8 | * the terms of the GNU General Public License version 2. This program | ||
9 | * is licensed "as is" without any warranty of any kind, whether express | ||
10 | * or implied. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/ioport.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/i2c.h> | ||
18 | #include <linux/timer.h> | ||
19 | #include <linux/completion.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/i2c-pnx.h> | ||
22 | #include <asm/hardware.h> | ||
23 | #include <asm/irq.h> | ||
24 | #include <asm/uaccess.h> | ||
25 | |||
26 | #define I2C_PNX_TIMEOUT 10 /* msec */ | ||
27 | #define I2C_PNX_SPEED_KHZ 100 | ||
28 | #define I2C_PNX_REGION_SIZE 0x100 | ||
29 | #define PNX_DEFAULT_FREQ 13 /* MHz */ | ||
30 | |||
31 | static inline int wait_timeout(long timeout, struct i2c_pnx_algo_data *data) | ||
32 | { | ||
33 | while (timeout > 0 && | ||
34 | (ioread32(I2C_REG_STS(data)) & mstatus_active)) { | ||
35 | mdelay(1); | ||
36 | timeout--; | ||
37 | } | ||
38 | return (timeout <= 0); | ||
39 | } | ||
40 | |||
41 | static inline int wait_reset(long timeout, struct i2c_pnx_algo_data *data) | ||
42 | { | ||
43 | while (timeout > 0 && | ||
44 | (ioread32(I2C_REG_CTL(data)) & mcntrl_reset)) { | ||
45 | mdelay(1); | ||
46 | timeout--; | ||
47 | } | ||
48 | return (timeout <= 0); | ||
49 | } | ||
50 | |||
51 | static inline void i2c_pnx_arm_timer(struct i2c_adapter *adap) | ||
52 | { | ||
53 | struct i2c_pnx_algo_data *data = adap->algo_data; | ||
54 | struct timer_list *timer = &data->mif.timer; | ||
55 | int expires = I2C_PNX_TIMEOUT / (1000 / HZ); | ||
56 | |||
57 | del_timer_sync(timer); | ||
58 | |||
59 | dev_dbg(&adap->dev, "Timer armed at %lu plus %u jiffies.\n", | ||
60 | jiffies, expires); | ||
61 | |||
62 | timer->expires = jiffies + expires; | ||
63 | timer->data = (unsigned long)adap; | ||
64 | |||
65 | add_timer(timer); | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * i2c_pnx_start - start a device | ||
70 | * @slave_addr: slave address | ||
71 | * @adap: pointer to adapter structure | ||
72 | * | ||
73 | * Generate a START signal in the desired mode. | ||
74 | */ | ||
75 | static int i2c_pnx_start(unsigned char slave_addr, struct i2c_adapter *adap) | ||
76 | { | ||
77 | struct i2c_pnx_algo_data *alg_data = adap->algo_data; | ||
78 | |||
79 | dev_dbg(&adap->dev, "%s(): addr 0x%x mode %d\n", __FUNCTION__, | ||
80 | slave_addr, alg_data->mif.mode); | ||
81 | |||
82 | /* Check for 7 bit slave addresses only */ | ||
83 | if (slave_addr & ~0x7f) { | ||
84 | dev_err(&adap->dev, "%s: Invalid slave address %x. " | ||
85 | "Only 7-bit addresses are supported\n", | ||
86 | adap->name, slave_addr); | ||
87 | return -EINVAL; | ||
88 | } | ||
89 | |||
90 | /* First, make sure bus is idle */ | ||
91 | if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) { | ||
92 | /* Somebody else is monopolizing the bus */ | ||
93 | dev_err(&adap->dev, "%s: Bus busy. Slave addr = %02x, " | ||
94 | "cntrl = %x, stat = %x\n", | ||
95 | adap->name, slave_addr, | ||
96 | ioread32(I2C_REG_CTL(alg_data)), | ||
97 | ioread32(I2C_REG_STS(alg_data))); | ||
98 | return -EBUSY; | ||
99 | } else if (ioread32(I2C_REG_STS(alg_data)) & mstatus_afi) { | ||
100 | /* Sorry, we lost the bus */ | ||
101 | dev_err(&adap->dev, "%s: Arbitration failure. " | ||
102 | "Slave addr = %02x\n", adap->name, slave_addr); | ||
103 | return -EIO; | ||
104 | } | ||
105 | |||
106 | /* | ||
107 | * OK, I2C is enabled and we have the bus. | ||
108 | * Clear the current TDI and AFI status flags. | ||
109 | */ | ||
110 | iowrite32(ioread32(I2C_REG_STS(alg_data)) | mstatus_tdi | mstatus_afi, | ||
111 | I2C_REG_STS(alg_data)); | ||
112 | |||
113 | dev_dbg(&adap->dev, "%s(): sending %#x\n", __FUNCTION__, | ||
114 | (slave_addr << 1) | start_bit | alg_data->mif.mode); | ||
115 | |||
116 | /* Write the slave address, START bit and R/W bit */ | ||
117 | iowrite32((slave_addr << 1) | start_bit | alg_data->mif.mode, | ||
118 | I2C_REG_TX(alg_data)); | ||
119 | |||
120 | dev_dbg(&adap->dev, "%s(): exit\n", __FUNCTION__); | ||
121 | |||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * i2c_pnx_stop - stop a device | ||
127 | * @adap: pointer to I2C adapter structure | ||
128 | * | ||
129 | * Generate a STOP signal to terminate the master transaction. | ||
130 | */ | ||
131 | static void i2c_pnx_stop(struct i2c_adapter *adap) | ||
132 | { | ||
133 | struct i2c_pnx_algo_data *alg_data = adap->algo_data; | ||
134 | /* Only 1 msec max timeout due to interrupt context */ | ||
135 | long timeout = 1000; | ||
136 | |||
137 | dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n", | ||
138 | __FUNCTION__, ioread32(I2C_REG_STS(alg_data))); | ||
139 | |||
140 | /* Write a STOP bit to TX FIFO */ | ||
141 | iowrite32(0xff | stop_bit, I2C_REG_TX(alg_data)); | ||
142 | |||
143 | /* Wait until the STOP is seen. */ | ||
144 | while (timeout > 0 && | ||
145 | (ioread32(I2C_REG_STS(alg_data)) & mstatus_active)) { | ||
146 | /* may be called from interrupt context */ | ||
147 | udelay(1); | ||
148 | timeout--; | ||
149 | } | ||
150 | |||
151 | dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n", | ||
152 | __FUNCTION__, ioread32(I2C_REG_STS(alg_data))); | ||
153 | } | ||
154 | |||
155 | /** | ||
156 | * i2c_pnx_master_xmit - transmit data to slave | ||
157 | * @adap: pointer to I2C adapter structure | ||
158 | * | ||
159 | * Sends one byte of data to the slave | ||
160 | */ | ||
161 | static int i2c_pnx_master_xmit(struct i2c_adapter *adap) | ||
162 | { | ||
163 | struct i2c_pnx_algo_data *alg_data = adap->algo_data; | ||
164 | u32 val; | ||
165 | |||
166 | dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n", | ||
167 | __FUNCTION__, ioread32(I2C_REG_STS(alg_data))); | ||
168 | |||
169 | if (alg_data->mif.len > 0) { | ||
170 | /* We still have something to talk about... */ | ||
171 | val = *alg_data->mif.buf++; | ||
172 | |||
173 | if (alg_data->mif.len == 1) { | ||
174 | val |= stop_bit; | ||
175 | if (!alg_data->last) | ||
176 | val |= start_bit; | ||
177 | } | ||
178 | |||
179 | alg_data->mif.len--; | ||
180 | iowrite32(val, I2C_REG_TX(alg_data)); | ||
181 | |||
182 | dev_dbg(&adap->dev, "%s(): xmit %#x [%d]\n", __FUNCTION__, | ||
183 | val, alg_data->mif.len + 1); | ||
184 | |||
185 | if (alg_data->mif.len == 0) { | ||
186 | if (alg_data->last) { | ||
187 | /* Wait until the STOP is seen. */ | ||
188 | if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) | ||
189 | dev_err(&adap->dev, "The bus is still " | ||
190 | "active after timeout\n"); | ||
191 | } | ||
192 | /* Disable master interrupts */ | ||
193 | iowrite32(ioread32(I2C_REG_CTL(alg_data)) & | ||
194 | ~(mcntrl_afie | mcntrl_naie | mcntrl_drmie), | ||
195 | I2C_REG_CTL(alg_data)); | ||
196 | |||
197 | del_timer_sync(&alg_data->mif.timer); | ||
198 | |||
199 | dev_dbg(&adap->dev, "%s(): Waking up xfer routine.\n", | ||
200 | __FUNCTION__); | ||
201 | |||
202 | complete(&alg_data->mif.complete); | ||
203 | } | ||
204 | } else if (alg_data->mif.len == 0) { | ||
205 | /* zero-sized transfer */ | ||
206 | i2c_pnx_stop(adap); | ||
207 | |||
208 | /* Disable master interrupts. */ | ||
209 | iowrite32(ioread32(I2C_REG_CTL(alg_data)) & | ||
210 | ~(mcntrl_afie | mcntrl_naie | mcntrl_drmie), | ||
211 | I2C_REG_CTL(alg_data)); | ||
212 | |||
213 | /* Stop timer. */ | ||
214 | del_timer_sync(&alg_data->mif.timer); | ||
215 | dev_dbg(&adap->dev, "%s(): Waking up xfer routine after " | ||
216 | "zero-xfer.\n", __FUNCTION__); | ||
217 | |||
218 | complete(&alg_data->mif.complete); | ||
219 | } | ||
220 | |||
221 | dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n", | ||
222 | __FUNCTION__, ioread32(I2C_REG_STS(alg_data))); | ||
223 | |||
224 | return 0; | ||
225 | } | ||
226 | |||
227 | /** | ||
228 | * i2c_pnx_master_rcv - receive data from slave | ||
229 | * @adap: pointer to I2C adapter structure | ||
230 | * | ||
231 | * Reads one byte data from the slave | ||
232 | */ | ||
233 | static int i2c_pnx_master_rcv(struct i2c_adapter *adap) | ||
234 | { | ||
235 | struct i2c_pnx_algo_data *alg_data = adap->algo_data; | ||
236 | unsigned int val = 0; | ||
237 | u32 ctl = 0; | ||
238 | |||
239 | dev_dbg(&adap->dev, "%s(): entering: stat = %04x.\n", | ||
240 | __FUNCTION__, ioread32(I2C_REG_STS(alg_data))); | ||
241 | |||
242 | /* Check, whether there is already data, | ||
243 | * or we didn't 'ask' for it yet. | ||
244 | */ | ||
245 | if (ioread32(I2C_REG_STS(alg_data)) & mstatus_rfe) { | ||
246 | dev_dbg(&adap->dev, "%s(): Write dummy data to fill " | ||
247 | "Rx-fifo...\n", __FUNCTION__); | ||
248 | |||
249 | if (alg_data->mif.len == 1) { | ||
250 | /* Last byte, do not acknowledge next rcv. */ | ||
251 | val |= stop_bit; | ||
252 | if (!alg_data->last) | ||
253 | val |= start_bit; | ||
254 | |||
255 | /* | ||
256 | * Enable interrupt RFDAIE (data in Rx fifo), | ||
257 | * and disable DRMIE (need data for Tx) | ||
258 | */ | ||
259 | ctl = ioread32(I2C_REG_CTL(alg_data)); | ||
260 | ctl |= mcntrl_rffie | mcntrl_daie; | ||
261 | ctl &= ~mcntrl_drmie; | ||
262 | iowrite32(ctl, I2C_REG_CTL(alg_data)); | ||
263 | } | ||
264 | |||
265 | /* | ||
266 | * Now we'll 'ask' for data: | ||
267 | * For each byte we want to receive, we must | ||
268 | * write a (dummy) byte to the Tx-FIFO. | ||
269 | */ | ||
270 | iowrite32(val, I2C_REG_TX(alg_data)); | ||
271 | |||
272 | return 0; | ||
273 | } | ||
274 | |||
275 | /* Handle data. */ | ||
276 | if (alg_data->mif.len > 0) { | ||
277 | val = ioread32(I2C_REG_RX(alg_data)); | ||
278 | *alg_data->mif.buf++ = (u8) (val & 0xff); | ||
279 | dev_dbg(&adap->dev, "%s(): rcv 0x%x [%d]\n", __FUNCTION__, val, | ||
280 | alg_data->mif.len); | ||
281 | |||
282 | alg_data->mif.len--; | ||
283 | if (alg_data->mif.len == 0) { | ||
284 | if (alg_data->last) | ||
285 | /* Wait until the STOP is seen. */ | ||
286 | if (wait_timeout(I2C_PNX_TIMEOUT, alg_data)) | ||
287 | dev_err(&adap->dev, "The bus is still " | ||
288 | "active after timeout\n"); | ||
289 | |||
290 | /* Disable master interrupts */ | ||
291 | ctl = ioread32(I2C_REG_CTL(alg_data)); | ||
292 | ctl &= ~(mcntrl_afie | mcntrl_naie | mcntrl_rffie | | ||
293 | mcntrl_drmie | mcntrl_daie); | ||
294 | iowrite32(ctl, I2C_REG_CTL(alg_data)); | ||
295 | |||
296 | /* Kill timer. */ | ||
297 | del_timer_sync(&alg_data->mif.timer); | ||
298 | complete(&alg_data->mif.complete); | ||
299 | } | ||
300 | } | ||
301 | |||
302 | dev_dbg(&adap->dev, "%s(): exiting: stat = %04x.\n", | ||
303 | __FUNCTION__, ioread32(I2C_REG_STS(alg_data))); | ||
304 | |||
305 | return 0; | ||
306 | } | ||
307 | |||
308 | static irqreturn_t | ||
309 | i2c_pnx_interrupt(int irq, void *dev_id, struct pt_regs *regs) | ||
310 | { | ||
311 | u32 stat, ctl; | ||
312 | struct i2c_adapter *adap = dev_id; | ||
313 | struct i2c_pnx_algo_data *alg_data = adap->algo_data; | ||
314 | |||
315 | dev_dbg(&adap->dev, "%s(): mstat = %x mctrl = %x, mode = %d\n", | ||
316 | __FUNCTION__, | ||
317 | ioread32(I2C_REG_STS(alg_data)), | ||
318 | ioread32(I2C_REG_CTL(alg_data)), | ||
319 | alg_data->mif.mode); | ||
320 | stat = ioread32(I2C_REG_STS(alg_data)); | ||
321 | |||
322 | /* let's see what kind of event this is */ | ||
323 | if (stat & mstatus_afi) { | ||
324 | /* We lost arbitration in the midst of a transfer */ | ||
325 | alg_data->mif.ret = -EIO; | ||
326 | |||
327 | /* Disable master interrupts. */ | ||
328 | ctl = ioread32(I2C_REG_CTL(alg_data)); | ||
329 | ctl &= ~(mcntrl_afie | mcntrl_naie | mcntrl_rffie | | ||
330 | mcntrl_drmie); | ||
331 | iowrite32(ctl, I2C_REG_CTL(alg_data)); | ||
332 | |||
333 | /* Stop timer, to prevent timeout. */ | ||
334 | del_timer_sync(&alg_data->mif.timer); | ||
335 | complete(&alg_data->mif.complete); | ||
336 | } else if (stat & mstatus_nai) { | ||
337 | /* Slave did not acknowledge, generate a STOP */ | ||
338 | dev_dbg(&adap->dev, "%s(): " | ||
339 | "Slave did not acknowledge, generating a STOP.\n", | ||
340 | __FUNCTION__); | ||
341 | i2c_pnx_stop(adap); | ||
342 | |||
343 | /* Disable master interrupts. */ | ||
344 | ctl = ioread32(I2C_REG_CTL(alg_data)); | ||
345 | ctl &= ~(mcntrl_afie | mcntrl_naie | mcntrl_rffie | | ||
346 | mcntrl_drmie); | ||
347 | iowrite32(ctl, I2C_REG_CTL(alg_data)); | ||
348 | |||
349 | /* Our return value. */ | ||
350 | alg_data->mif.ret = -EIO; | ||
351 | |||
352 | /* Stop timer, to prevent timeout. */ | ||
353 | del_timer_sync(&alg_data->mif.timer); | ||
354 | complete(&alg_data->mif.complete); | ||
355 | } else { | ||
356 | /* | ||
357 | * Two options: | ||
358 | * - Master Tx needs data. | ||
359 | * - There is data in the Rx-fifo | ||
360 | * The latter is only the case if we have requested for data, | ||
361 | * via a dummy write. (See 'i2c_pnx_master_rcv'.) | ||
362 | * We therefore check, as a sanity check, whether that interrupt | ||
363 | * has been enabled. | ||
364 | */ | ||
365 | if ((stat & mstatus_drmi) || !(stat & mstatus_rfe)) { | ||
366 | if (alg_data->mif.mode == I2C_SMBUS_WRITE) { | ||
367 | i2c_pnx_master_xmit(adap); | ||
368 | } else if (alg_data->mif.mode == I2C_SMBUS_READ) { | ||
369 | i2c_pnx_master_rcv(adap); | ||
370 | } | ||
371 | } | ||
372 | } | ||
373 | |||
374 | /* Clear TDI and AFI bits */ | ||
375 | stat = ioread32(I2C_REG_STS(alg_data)); | ||
376 | iowrite32(stat | mstatus_tdi | mstatus_afi, I2C_REG_STS(alg_data)); | ||
377 | |||
378 | dev_dbg(&adap->dev, "%s(): exiting, stat = %x ctrl = %x.\n", | ||
379 | __FUNCTION__, ioread32(I2C_REG_STS(alg_data)), | ||
380 | ioread32(I2C_REG_CTL(alg_data))); | ||
381 | |||
382 | return IRQ_HANDLED; | ||
383 | } | ||
384 | |||
385 | static void i2c_pnx_timeout(unsigned long data) | ||
386 | { | ||
387 | struct i2c_adapter *adap = (struct i2c_adapter *)data; | ||
388 | struct i2c_pnx_algo_data *alg_data = adap->algo_data; | ||
389 | u32 ctl; | ||
390 | |||
391 | dev_err(&adap->dev, "Master timed out. stat = %04x, cntrl = %04x. " | ||
392 | "Resetting master...\n", | ||
393 | ioread32(I2C_REG_STS(alg_data)), | ||
394 | ioread32(I2C_REG_CTL(alg_data))); | ||
395 | |||
396 | /* Reset master and disable interrupts */ | ||
397 | ctl = ioread32(I2C_REG_CTL(alg_data)); | ||
398 | ctl &= ~(mcntrl_afie | mcntrl_naie | mcntrl_rffie | mcntrl_drmie); | ||
399 | iowrite32(ctl, I2C_REG_CTL(alg_data)); | ||
400 | |||
401 | ctl |= mcntrl_reset; | ||
402 | iowrite32(ctl, I2C_REG_CTL(alg_data)); | ||
403 | wait_reset(I2C_PNX_TIMEOUT, alg_data); | ||
404 | alg_data->mif.ret = -EIO; | ||
405 | complete(&alg_data->mif.complete); | ||
406 | } | ||
407 | |||
408 | static inline void bus_reset_if_active(struct i2c_adapter *adap) | ||
409 | { | ||
410 | struct i2c_pnx_algo_data *alg_data = adap->algo_data; | ||
411 | u32 stat; | ||
412 | |||
413 | if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_active) { | ||
414 | dev_err(&adap->dev, | ||
415 | "%s: Bus is still active after xfer. Reset it...\n", | ||
416 | adap->name); | ||
417 | iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset, | ||
418 | I2C_REG_CTL(alg_data)); | ||
419 | wait_reset(I2C_PNX_TIMEOUT, alg_data); | ||
420 | } else if (!(stat & mstatus_rfe) || !(stat & mstatus_tfe)) { | ||
421 | /* If there is data in the fifo's after transfer, | ||
422 | * flush fifo's by reset. | ||
423 | */ | ||
424 | iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset, | ||
425 | I2C_REG_CTL(alg_data)); | ||
426 | wait_reset(I2C_PNX_TIMEOUT, alg_data); | ||
427 | } else if (stat & mstatus_nai) { | ||
428 | iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset, | ||
429 | I2C_REG_CTL(alg_data)); | ||
430 | wait_reset(I2C_PNX_TIMEOUT, alg_data); | ||
431 | } | ||
432 | } | ||
433 | |||
434 | /** | ||
435 | * i2c_pnx_xfer - generic transfer entry point | ||
436 | * @adap: pointer to I2C adapter structure | ||
437 | * @msgs: array of messages | ||
438 | * @num: number of messages | ||
439 | * | ||
440 | * Initiates the transfer | ||
441 | */ | ||
442 | static int | ||
443 | i2c_pnx_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | ||
444 | { | ||
445 | struct i2c_msg *pmsg; | ||
446 | int rc = 0, completed = 0, i; | ||
447 | struct i2c_pnx_algo_data *alg_data = adap->algo_data; | ||
448 | u32 stat = ioread32(I2C_REG_STS(alg_data)); | ||
449 | |||
450 | dev_dbg(&adap->dev, "%s(): entering: %d messages, stat = %04x.\n", | ||
451 | __FUNCTION__, num, ioread32(I2C_REG_STS(alg_data))); | ||
452 | |||
453 | bus_reset_if_active(adap); | ||
454 | |||
455 | /* Process transactions in a loop. */ | ||
456 | for (i = 0; rc >= 0 && i < num; i++) { | ||
457 | u8 addr; | ||
458 | |||
459 | pmsg = &msgs[i]; | ||
460 | addr = pmsg->addr; | ||
461 | |||
462 | if (pmsg->flags & I2C_M_TEN) { | ||
463 | dev_err(&adap->dev, | ||
464 | "%s: 10 bits addr not supported!\n", | ||
465 | adap->name); | ||
466 | rc = -EINVAL; | ||
467 | break; | ||
468 | } | ||
469 | |||
470 | alg_data->mif.buf = pmsg->buf; | ||
471 | alg_data->mif.len = pmsg->len; | ||
472 | alg_data->mif.mode = (pmsg->flags & I2C_M_RD) ? | ||
473 | I2C_SMBUS_READ : I2C_SMBUS_WRITE; | ||
474 | alg_data->mif.ret = 0; | ||
475 | alg_data->last = (i == num - 1); | ||
476 | |||
477 | dev_dbg(&adap->dev, "%s(): mode %d, %d bytes\n", __FUNCTION__, | ||
478 | alg_data->mif.mode, | ||
479 | alg_data->mif.len); | ||
480 | |||
481 | i2c_pnx_arm_timer(adap); | ||
482 | |||
483 | /* initialize the completion var */ | ||
484 | init_completion(&alg_data->mif.complete); | ||
485 | |||
486 | /* Enable master interrupt */ | ||
487 | iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_afie | | ||
488 | mcntrl_naie | mcntrl_drmie, | ||
489 | I2C_REG_CTL(alg_data)); | ||
490 | |||
491 | /* Put start-code and slave-address on the bus. */ | ||
492 | rc = i2c_pnx_start(addr, adap); | ||
493 | if (rc < 0) | ||
494 | break; | ||
495 | |||
496 | /* Wait for completion */ | ||
497 | wait_for_completion(&alg_data->mif.complete); | ||
498 | |||
499 | if (!(rc = alg_data->mif.ret)) | ||
500 | completed++; | ||
501 | dev_dbg(&adap->dev, "%s(): Complete, return code = %d.\n", | ||
502 | __FUNCTION__, rc); | ||
503 | |||
504 | /* Clear TDI and AFI bits in case they are set. */ | ||
505 | if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_tdi) { | ||
506 | dev_dbg(&adap->dev, | ||
507 | "%s: TDI still set... clearing now.\n", | ||
508 | adap->name); | ||
509 | iowrite32(stat, I2C_REG_STS(alg_data)); | ||
510 | } | ||
511 | if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_afi) { | ||
512 | dev_dbg(&adap->dev, | ||
513 | "%s: AFI still set... clearing now.\n", | ||
514 | adap->name); | ||
515 | iowrite32(stat, I2C_REG_STS(alg_data)); | ||
516 | } | ||
517 | } | ||
518 | |||
519 | bus_reset_if_active(adap); | ||
520 | |||
521 | /* Cleanup to be sure... */ | ||
522 | alg_data->mif.buf = NULL; | ||
523 | alg_data->mif.len = 0; | ||
524 | |||
525 | dev_dbg(&adap->dev, "%s(): exiting, stat = %x\n", | ||
526 | __FUNCTION__, ioread32(I2C_REG_STS(alg_data))); | ||
527 | |||
528 | if (completed != num) | ||
529 | return ((rc < 0) ? rc : -EREMOTEIO); | ||
530 | |||
531 | return num; | ||
532 | } | ||
533 | |||
534 | static u32 i2c_pnx_func(struct i2c_adapter *adapter) | ||
535 | { | ||
536 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; | ||
537 | } | ||
538 | |||
539 | static struct i2c_algorithm pnx_algorithm = { | ||
540 | .master_xfer = i2c_pnx_xfer, | ||
541 | .functionality = i2c_pnx_func, | ||
542 | }; | ||
543 | |||
544 | static int i2c_pnx_controller_suspend(struct platform_device *pdev, | ||
545 | pm_message_t state) | ||
546 | { | ||
547 | struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev); | ||
548 | return i2c_pnx->suspend(pdev, state); | ||
549 | } | ||
550 | |||
551 | static int i2c_pnx_controller_resume(struct platform_device *pdev) | ||
552 | { | ||
553 | struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev); | ||
554 | return i2c_pnx->resume(pdev); | ||
555 | } | ||
556 | |||
557 | static int __devinit i2c_pnx_probe(struct platform_device *pdev) | ||
558 | { | ||
559 | unsigned long tmp; | ||
560 | int ret = 0; | ||
561 | struct i2c_pnx_algo_data *alg_data; | ||
562 | int freq_mhz; | ||
563 | struct i2c_pnx_data *i2c_pnx = pdev->dev.platform_data; | ||
564 | |||
565 | if (!i2c_pnx || !i2c_pnx->adapter) { | ||
566 | dev_err(&pdev->dev, "%s: no platform data supplied\n", | ||
567 | __FUNCTION__); | ||
568 | ret = -EINVAL; | ||
569 | goto out; | ||
570 | } | ||
571 | |||
572 | platform_set_drvdata(pdev, i2c_pnx); | ||
573 | |||
574 | if (i2c_pnx->calculate_input_freq) | ||
575 | freq_mhz = i2c_pnx->calculate_input_freq(pdev); | ||
576 | else { | ||
577 | freq_mhz = PNX_DEFAULT_FREQ; | ||
578 | dev_info(&pdev->dev, "Setting bus frequency to default value: " | ||
579 | "%d MHz", freq_mhz); | ||
580 | } | ||
581 | |||
582 | i2c_pnx->adapter->algo = &pnx_algorithm; | ||
583 | |||
584 | alg_data = i2c_pnx->adapter->algo_data; | ||
585 | init_timer(&alg_data->mif.timer); | ||
586 | alg_data->mif.timer.function = i2c_pnx_timeout; | ||
587 | alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter; | ||
588 | |||
589 | /* Register I/O resource */ | ||
590 | if (!request_region(alg_data->base, I2C_PNX_REGION_SIZE, pdev->name)) { | ||
591 | dev_err(&pdev->dev, | ||
592 | "I/O region 0x%08x for I2C already in use.\n", | ||
593 | alg_data->base); | ||
594 | ret = -ENODEV; | ||
595 | goto out_drvdata; | ||
596 | } | ||
597 | |||
598 | if (!(alg_data->ioaddr = | ||
599 | (u32)ioremap(alg_data->base, I2C_PNX_REGION_SIZE))) { | ||
600 | dev_err(&pdev->dev, "Couldn't ioremap I2C I/O region\n"); | ||
601 | ret = -ENOMEM; | ||
602 | goto out_release; | ||
603 | } | ||
604 | |||
605 | i2c_pnx->set_clock_run(pdev); | ||
606 | |||
607 | /* | ||
608 | * Clock Divisor High This value is the number of system clocks | ||
609 | * the serial clock (SCL) will be high. | ||
610 | * For example, if the system clock period is 50 ns and the maximum | ||
611 | * desired serial period is 10000 ns (100 kHz), then CLKHI would be | ||
612 | * set to 0.5*(f_sys/f_i2c)-2=0.5*(20e6/100e3)-2=98. The actual value | ||
613 | * programmed into CLKHI will vary from this slightly due to | ||
614 | * variations in the output pad's rise and fall times as well as | ||
615 | * the deglitching filter length. | ||
616 | */ | ||
617 | |||
618 | tmp = ((freq_mhz * 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2; | ||
619 | iowrite32(tmp, I2C_REG_CKH(alg_data)); | ||
620 | iowrite32(tmp, I2C_REG_CKL(alg_data)); | ||
621 | |||
622 | iowrite32(mcntrl_reset, I2C_REG_CTL(alg_data)); | ||
623 | if (wait_reset(I2C_PNX_TIMEOUT, alg_data)) { | ||
624 | ret = -ENODEV; | ||
625 | goto out_unmap; | ||
626 | } | ||
627 | init_completion(&alg_data->mif.complete); | ||
628 | |||
629 | ret = request_irq(alg_data->irq, i2c_pnx_interrupt, | ||
630 | 0, pdev->name, i2c_pnx->adapter); | ||
631 | if (ret) | ||
632 | goto out_clock; | ||
633 | |||
634 | /* Register this adapter with the I2C subsystem */ | ||
635 | i2c_pnx->adapter->dev.parent = &pdev->dev; | ||
636 | ret = i2c_add_adapter(i2c_pnx->adapter); | ||
637 | if (ret < 0) { | ||
638 | dev_err(&pdev->dev, "I2C: Failed to add bus\n"); | ||
639 | goto out_irq; | ||
640 | } | ||
641 | |||
642 | dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n", | ||
643 | i2c_pnx->adapter->name, alg_data->base, alg_data->irq); | ||
644 | |||
645 | return 0; | ||
646 | |||
647 | out_irq: | ||
648 | free_irq(alg_data->irq, alg_data); | ||
649 | out_clock: | ||
650 | i2c_pnx->set_clock_stop(pdev); | ||
651 | out_unmap: | ||
652 | iounmap((void *)alg_data->ioaddr); | ||
653 | out_release: | ||
654 | release_region(alg_data->base, I2C_PNX_REGION_SIZE); | ||
655 | out_drvdata: | ||
656 | platform_set_drvdata(pdev, NULL); | ||
657 | out: | ||
658 | return ret; | ||
659 | } | ||
660 | |||
661 | static int __devexit i2c_pnx_remove(struct platform_device *pdev) | ||
662 | { | ||
663 | struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev); | ||
664 | struct i2c_adapter *adap = i2c_pnx->adapter; | ||
665 | struct i2c_pnx_algo_data *alg_data = adap->algo_data; | ||
666 | |||
667 | free_irq(alg_data->irq, alg_data); | ||
668 | i2c_del_adapter(adap); | ||
669 | i2c_pnx->set_clock_stop(pdev); | ||
670 | iounmap((void *)alg_data->ioaddr); | ||
671 | release_region(alg_data->base, I2C_PNX_REGION_SIZE); | ||
672 | platform_set_drvdata(pdev, NULL); | ||
673 | |||
674 | return 0; | ||
675 | } | ||
676 | |||
677 | static struct platform_driver i2c_pnx_driver = { | ||
678 | .driver = { | ||
679 | .name = "pnx-i2c", | ||
680 | .owner = THIS_MODULE, | ||
681 | }, | ||
682 | .probe = i2c_pnx_probe, | ||
683 | .remove = __devexit_p(i2c_pnx_remove), | ||
684 | .suspend = i2c_pnx_controller_suspend, | ||
685 | .resume = i2c_pnx_controller_resume, | ||
686 | }; | ||
687 | |||
688 | static int __init i2c_adap_pnx_init(void) | ||
689 | { | ||
690 | return platform_driver_register(&i2c_pnx_driver); | ||
691 | } | ||
692 | |||
693 | static void __exit i2c_adap_pnx_exit(void) | ||
694 | { | ||
695 | platform_driver_unregister(&i2c_pnx_driver); | ||
696 | } | ||
697 | |||
698 | MODULE_AUTHOR("Vitaly Wool, Dennis Kovalev <source@mvista.com>"); | ||
699 | MODULE_DESCRIPTION("I2C driver for Philips IP3204-based I2C busses"); | ||
700 | MODULE_LICENSE("GPL"); | ||
701 | |||
702 | #ifdef CONFIG_I2C_PNX_EARLY | ||
703 | /* We need to make sure I2C is initialized before USB */ | ||
704 | subsys_initcall(i2c_adap_pnx_init); | ||
705 | #else | ||
706 | mudule_init(i2c_adap_pnx_init); | ||
707 | #endif | ||
708 | module_exit(i2c_adap_pnx_exit); | ||
diff --git a/drivers/i2c/busses/i2c-prosavage.c b/drivers/i2c/busses/i2c-prosavage.c index 7745e21874a8..07c1f1e27df1 100644 --- a/drivers/i2c/busses/i2c-prosavage.c +++ b/drivers/i2c/busses/i2c-prosavage.c | |||
@@ -212,7 +212,7 @@ static void prosavage_remove(struct pci_dev *dev) | |||
212 | if (chip->i2c_bus[i].adap_ok == 0) | 212 | if (chip->i2c_bus[i].adap_ok == 0) |
213 | continue; | 213 | continue; |
214 | 214 | ||
215 | ret = i2c_bit_del_bus(&chip->i2c_bus[i].adap); | 215 | ret = i2c_del_adapter(&chip->i2c_bus[i].adap); |
216 | if (ret) { | 216 | if (ret) { |
217 | dev_err(&dev->dev, "%s not removed\n", | 217 | dev_err(&dev->dev, "%s not removed\n", |
218 | chip->i2c_bus[i].adap.name); | 218 | chip->i2c_bus[i].adap.name); |
diff --git a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c index 209f47ea1750..844b4ff90893 100644 --- a/drivers/i2c/busses/i2c-savage4.c +++ b/drivers/i2c/busses/i2c-savage4.c | |||
@@ -173,7 +173,7 @@ static int __devinit savage4_probe(struct pci_dev *dev, const struct pci_device_ | |||
173 | 173 | ||
174 | static void __devexit savage4_remove(struct pci_dev *dev) | 174 | static void __devexit savage4_remove(struct pci_dev *dev) |
175 | { | 175 | { |
176 | i2c_bit_del_bus(&savage4_i2c_adapter); | 176 | i2c_del_adapter(&savage4_i2c_adapter); |
177 | iounmap(ioaddr); | 177 | iounmap(ioaddr); |
178 | } | 178 | } |
179 | 179 | ||
diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c new file mode 100644 index 000000000000..081d9578ce10 --- /dev/null +++ b/drivers/i2c/busses/i2c-versatile.c | |||
@@ -0,0 +1,153 @@ | |||
1 | /* | ||
2 | * i2c-versatile.c | ||
3 | * | ||
4 | * Copyright (C) 2006 ARM Ltd. | ||
5 | * written by Russell King, Deep Blue Solutions Ltd. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/i2c.h> | ||
14 | #include <linux/i2c-algo-bit.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | |||
18 | #include <asm/io.h> | ||
19 | |||
20 | #define I2C_CONTROL 0x00 | ||
21 | #define I2C_CONTROLS 0x00 | ||
22 | #define I2C_CONTROLC 0x04 | ||
23 | #define SCL (1 << 0) | ||
24 | #define SDA (1 << 1) | ||
25 | |||
26 | struct i2c_versatile { | ||
27 | struct i2c_adapter adap; | ||
28 | struct i2c_algo_bit_data algo; | ||
29 | void __iomem *base; | ||
30 | }; | ||
31 | |||
32 | static void i2c_versatile_setsda(void *data, int state) | ||
33 | { | ||
34 | struct i2c_versatile *i2c = data; | ||
35 | |||
36 | writel(SDA, i2c->base + (state ? I2C_CONTROLS : I2C_CONTROLC)); | ||
37 | } | ||
38 | |||
39 | static void i2c_versatile_setscl(void *data, int state) | ||
40 | { | ||
41 | struct i2c_versatile *i2c = data; | ||
42 | |||
43 | writel(SCL, i2c->base + (state ? I2C_CONTROLS : I2C_CONTROLC)); | ||
44 | } | ||
45 | |||
46 | static int i2c_versatile_getsda(void *data) | ||
47 | { | ||
48 | struct i2c_versatile *i2c = data; | ||
49 | return !!(readl(i2c->base + I2C_CONTROL) & SDA); | ||
50 | } | ||
51 | |||
52 | static int i2c_versatile_getscl(void *data) | ||
53 | { | ||
54 | struct i2c_versatile *i2c = data; | ||
55 | return !!(readl(i2c->base + I2C_CONTROL) & SCL); | ||
56 | } | ||
57 | |||
58 | static struct i2c_algo_bit_data i2c_versatile_algo = { | ||
59 | .setsda = i2c_versatile_setsda, | ||
60 | .setscl = i2c_versatile_setscl, | ||
61 | .getsda = i2c_versatile_getsda, | ||
62 | .getscl = i2c_versatile_getscl, | ||
63 | .udelay = 30, | ||
64 | .timeout = HZ, | ||
65 | }; | ||
66 | |||
67 | static int i2c_versatile_probe(struct platform_device *dev) | ||
68 | { | ||
69 | struct i2c_versatile *i2c; | ||
70 | struct resource *r; | ||
71 | int ret; | ||
72 | |||
73 | r = platform_get_resource(dev, IORESOURCE_MEM, 0); | ||
74 | if (!r) { | ||
75 | ret = -EINVAL; | ||
76 | goto err_out; | ||
77 | } | ||
78 | |||
79 | if (!request_mem_region(r->start, r->end - r->start + 1, "versatile-i2c")) { | ||
80 | ret = -EBUSY; | ||
81 | goto err_out; | ||
82 | } | ||
83 | |||
84 | i2c = kzalloc(sizeof(struct i2c_versatile), GFP_KERNEL); | ||
85 | if (!i2c) { | ||
86 | ret = -ENOMEM; | ||
87 | goto err_release; | ||
88 | } | ||
89 | |||
90 | i2c->base = ioremap(r->start, r->end - r->start + 1); | ||
91 | if (!i2c->base) { | ||
92 | ret = -ENOMEM; | ||
93 | goto err_free; | ||
94 | } | ||
95 | |||
96 | writel(SCL | SDA, i2c->base + I2C_CONTROLS); | ||
97 | |||
98 | i2c->adap.owner = THIS_MODULE; | ||
99 | strlcpy(i2c->adap.name, "Versatile I2C adapter", sizeof(i2c->adap.name)); | ||
100 | i2c->adap.algo_data = &i2c->algo; | ||
101 | i2c->adap.dev.parent = &dev->dev; | ||
102 | i2c->algo = i2c_versatile_algo; | ||
103 | i2c->algo.data = i2c; | ||
104 | |||
105 | ret = i2c_bit_add_bus(&i2c->adap); | ||
106 | if (ret >= 0) { | ||
107 | platform_set_drvdata(dev, i2c); | ||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | iounmap(i2c->base); | ||
112 | err_free: | ||
113 | kfree(i2c); | ||
114 | err_release: | ||
115 | release_mem_region(r->start, r->end - r->start + 1); | ||
116 | err_out: | ||
117 | return ret; | ||
118 | } | ||
119 | |||
120 | static int i2c_versatile_remove(struct platform_device *dev) | ||
121 | { | ||
122 | struct i2c_versatile *i2c = platform_get_drvdata(dev); | ||
123 | |||
124 | platform_set_drvdata(dev, NULL); | ||
125 | |||
126 | i2c_del_adapter(&i2c->adap); | ||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | static struct platform_driver i2c_versatile_driver = { | ||
131 | .probe = i2c_versatile_probe, | ||
132 | .remove = i2c_versatile_remove, | ||
133 | .driver = { | ||
134 | .name = "versatile-i2c", | ||
135 | .owner = THIS_MODULE, | ||
136 | }, | ||
137 | }; | ||
138 | |||
139 | static int __init i2c_versatile_init(void) | ||
140 | { | ||
141 | return platform_driver_register(&i2c_versatile_driver); | ||
142 | } | ||
143 | |||
144 | static void __exit i2c_versatile_exit(void) | ||
145 | { | ||
146 | platform_driver_unregister(&i2c_versatile_driver); | ||
147 | } | ||
148 | |||
149 | module_init(i2c_versatile_init); | ||
150 | module_exit(i2c_versatile_exit); | ||
151 | |||
152 | MODULE_DESCRIPTION("ARM Versatile I2C bus driver"); | ||
153 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c index 910e200ad500..15d7e00e47e6 100644 --- a/drivers/i2c/busses/i2c-via.c +++ b/drivers/i2c/busses/i2c-via.c | |||
@@ -151,7 +151,7 @@ static int __devinit vt586b_probe(struct pci_dev *dev, const struct pci_device_i | |||
151 | 151 | ||
152 | static void __devexit vt586b_remove(struct pci_dev *dev) | 152 | static void __devexit vt586b_remove(struct pci_dev *dev) |
153 | { | 153 | { |
154 | i2c_bit_del_bus(&vt586b_adapter); | 154 | i2c_del_adapter(&vt586b_adapter); |
155 | release_region(I2C_DIR, IOSPACE); | 155 | release_region(I2C_DIR, IOSPACE); |
156 | pm_io_base = 0; | 156 | pm_io_base = 0; |
157 | } | 157 | } |
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c index 6c8d25183382..b0377b81744b 100644 --- a/drivers/i2c/busses/i2c-voodoo3.c +++ b/drivers/i2c/busses/i2c-voodoo3.c | |||
@@ -211,14 +211,14 @@ static int __devinit voodoo3_probe(struct pci_dev *dev, const struct pci_device_ | |||
211 | return retval; | 211 | return retval; |
212 | retval = i2c_bit_add_bus(&voodoo3_ddc_adapter); | 212 | retval = i2c_bit_add_bus(&voodoo3_ddc_adapter); |
213 | if (retval) | 213 | if (retval) |
214 | i2c_bit_del_bus(&voodoo3_i2c_adapter); | 214 | i2c_del_adapter(&voodoo3_i2c_adapter); |
215 | return retval; | 215 | return retval; |
216 | } | 216 | } |
217 | 217 | ||
218 | static void __devexit voodoo3_remove(struct pci_dev *dev) | 218 | static void __devexit voodoo3_remove(struct pci_dev *dev) |
219 | { | 219 | { |
220 | i2c_bit_del_bus(&voodoo3_i2c_adapter); | 220 | i2c_del_adapter(&voodoo3_i2c_adapter); |
221 | i2c_bit_del_bus(&voodoo3_ddc_adapter); | 221 | i2c_del_adapter(&voodoo3_ddc_adapter); |
222 | iounmap(ioaddr); | 222 | iounmap(ioaddr); |
223 | } | 223 | } |
224 | 224 | ||
diff --git a/drivers/i2c/busses/scx200_i2c.c b/drivers/i2c/busses/scx200_i2c.c index 8ddbae4fafe6..6cd96e43aa72 100644 --- a/drivers/i2c/busses/scx200_i2c.c +++ b/drivers/i2c/busses/scx200_i2c.c | |||
@@ -116,7 +116,7 @@ static int scx200_i2c_init(void) | |||
116 | 116 | ||
117 | static void scx200_i2c_cleanup(void) | 117 | static void scx200_i2c_cleanup(void) |
118 | { | 118 | { |
119 | i2c_bit_del_bus(&scx200_i2c_ops); | 119 | i2c_del_adapter(&scx200_i2c_ops); |
120 | } | 120 | } |
121 | 121 | ||
122 | module_init(scx200_i2c_init); | 122 | module_init(scx200_i2c_init); |
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 93d483b8b770..ec17d6b684a2 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c | |||
@@ -347,13 +347,19 @@ static void ds1337_init_client(struct i2c_client *client) | |||
347 | 347 | ||
348 | if ((status & 0x80) || (control & 0x80)) { | 348 | if ((status & 0x80) || (control & 0x80)) { |
349 | /* RTC not running */ | 349 | /* RTC not running */ |
350 | u8 buf[16]; | 350 | u8 buf[1+16]; /* First byte is interpreted as address */ |
351 | struct i2c_msg msg[1]; | 351 | struct i2c_msg msg[1]; |
352 | 352 | ||
353 | dev_dbg(&client->dev, "%s: RTC not running!\n", __FUNCTION__); | 353 | dev_dbg(&client->dev, "%s: RTC not running!\n", __FUNCTION__); |
354 | 354 | ||
355 | /* Initialize all, including STATUS and CONTROL to zero */ | 355 | /* Initialize all, including STATUS and CONTROL to zero */ |
356 | memset(buf, 0, sizeof(buf)); | 356 | memset(buf, 0, sizeof(buf)); |
357 | |||
358 | /* Write valid values in the date/time registers */ | ||
359 | buf[1+DS1337_REG_DAY] = 1; | ||
360 | buf[1+DS1337_REG_DATE] = 1; | ||
361 | buf[1+DS1337_REG_MONTH] = 1; | ||
362 | |||
357 | msg[0].addr = client->addr; | 363 | msg[0].addr = client->addr; |
358 | msg[0].flags = 0; | 364 | msg[0].flags = 0; |
359 | msg[0].len = sizeof(buf); | 365 | msg[0].len = sizeof(buf); |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 7ca81f42d14b..3e31f1d265c9 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -127,20 +127,17 @@ static ssize_t show_client_name(struct device *dev, struct device_attribute *att | |||
127 | return sprintf(buf, "%s\n", client->name); | 127 | return sprintf(buf, "%s\n", client->name); |
128 | } | 128 | } |
129 | 129 | ||
130 | /* | 130 | /* |
131 | * We can't use the DEVICE_ATTR() macro here as we want the same filename for a | 131 | * We can't use the DEVICE_ATTR() macro here, as we used the same name for |
132 | * different type of a device. So beware if the DEVICE_ATTR() macro ever | 132 | * an i2c adapter attribute (above). |
133 | * changes, this definition will also have to change. | ||
134 | */ | 133 | */ |
135 | static struct device_attribute dev_attr_client_name = { | 134 | static struct device_attribute dev_attr_client_name = |
136 | .attr = {.name = "name", .mode = S_IRUGO, .owner = THIS_MODULE }, | 135 | __ATTR(name, S_IRUGO, &show_client_name, NULL); |
137 | .show = &show_client_name, | ||
138 | }; | ||
139 | 136 | ||
140 | 137 | ||
141 | /* --------------------------------------------------- | 138 | /* --------------------------------------------------- |
142 | * registering functions | 139 | * registering functions |
143 | * --------------------------------------------------- | 140 | * --------------------------------------------------- |
144 | */ | 141 | */ |
145 | 142 | ||
146 | /* ----- | 143 | /* ----- |
@@ -314,7 +311,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) | |||
314 | res = driver_register(&driver->driver); | 311 | res = driver_register(&driver->driver); |
315 | if (res) | 312 | if (res) |
316 | return res; | 313 | return res; |
317 | 314 | ||
318 | mutex_lock(&core_lists); | 315 | mutex_lock(&core_lists); |
319 | 316 | ||
320 | list_add_tail(&driver->list,&drivers); | 317 | list_add_tail(&driver->list,&drivers); |
@@ -338,13 +335,13 @@ int i2c_del_driver(struct i2c_driver *driver) | |||
338 | struct list_head *item1, *item2, *_n; | 335 | struct list_head *item1, *item2, *_n; |
339 | struct i2c_client *client; | 336 | struct i2c_client *client; |
340 | struct i2c_adapter *adap; | 337 | struct i2c_adapter *adap; |
341 | 338 | ||
342 | int res = 0; | 339 | int res = 0; |
343 | 340 | ||
344 | mutex_lock(&core_lists); | 341 | mutex_lock(&core_lists); |
345 | 342 | ||
346 | /* Have a look at each adapter, if clients of this driver are still | 343 | /* Have a look at each adapter, if clients of this driver are still |
347 | * attached. If so, detach them to be able to kill the driver | 344 | * attached. If so, detach them to be able to kill the driver |
348 | * afterwards. | 345 | * afterwards. |
349 | */ | 346 | */ |
350 | list_for_each(item1,&adapters) { | 347 | list_for_each(item1,&adapters) { |
@@ -419,14 +416,14 @@ int i2c_attach_client(struct i2c_client *client) | |||
419 | goto out_unlock; | 416 | goto out_unlock; |
420 | } | 417 | } |
421 | list_add_tail(&client->list,&adapter->clients); | 418 | list_add_tail(&client->list,&adapter->clients); |
422 | 419 | ||
423 | client->usage_count = 0; | 420 | client->usage_count = 0; |
424 | 421 | ||
425 | client->dev.parent = &client->adapter->dev; | 422 | client->dev.parent = &client->adapter->dev; |
426 | client->dev.driver = &client->driver->driver; | 423 | client->dev.driver = &client->driver->driver; |
427 | client->dev.bus = &i2c_bus_type; | 424 | client->dev.bus = &i2c_bus_type; |
428 | client->dev.release = &i2c_client_release; | 425 | client->dev.release = &i2c_client_release; |
429 | 426 | ||
430 | snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), | 427 | snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), |
431 | "%d-%04x", i2c_adapter_id(adapter), client->addr); | 428 | "%d-%04x", i2c_adapter_id(adapter), client->addr); |
432 | dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n", | 429 | dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n", |
@@ -467,7 +464,7 @@ int i2c_detach_client(struct i2c_client *client) | |||
467 | { | 464 | { |
468 | struct i2c_adapter *adapter = client->adapter; | 465 | struct i2c_adapter *adapter = client->adapter; |
469 | int res = 0; | 466 | int res = 0; |
470 | 467 | ||
471 | if (client->usage_count > 0) { | 468 | if (client->usage_count > 0) { |
472 | dev_warn(&client->dev, "Client [%s] still busy, " | 469 | dev_warn(&client->dev, "Client [%s] still busy, " |
473 | "can't detach\n", client->name); | 470 | "can't detach\n", client->name); |
@@ -535,10 +532,10 @@ int i2c_release_client(struct i2c_client *client) | |||
535 | __FUNCTION__); | 532 | __FUNCTION__); |
536 | return -EPERM; | 533 | return -EPERM; |
537 | } | 534 | } |
538 | 535 | ||
539 | client->usage_count--; | 536 | client->usage_count--; |
540 | i2c_dec_use_client(client); | 537 | i2c_dec_use_client(client); |
541 | 538 | ||
542 | return 0; | 539 | return 0; |
543 | } | 540 | } |
544 | 541 | ||
@@ -603,7 +600,7 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num) | |||
603 | } | 600 | } |
604 | #endif | 601 | #endif |
605 | 602 | ||
606 | mutex_lock(&adap->bus_lock); | 603 | mutex_lock_nested(&adap->bus_lock, adap->level); |
607 | ret = adap->algo->master_xfer(adap,msgs,num); | 604 | ret = adap->algo->master_xfer(adap,msgs,num); |
608 | mutex_unlock(&adap->bus_lock); | 605 | mutex_unlock(&adap->bus_lock); |
609 | 606 | ||
@@ -624,7 +621,7 @@ int i2c_master_send(struct i2c_client *client,const char *buf ,int count) | |||
624 | msg.flags = client->flags & I2C_M_TEN; | 621 | msg.flags = client->flags & I2C_M_TEN; |
625 | msg.len = count; | 622 | msg.len = count; |
626 | msg.buf = (char *)buf; | 623 | msg.buf = (char *)buf; |
627 | 624 | ||
628 | ret = i2c_transfer(adap, &msg, 1); | 625 | ret = i2c_transfer(adap, &msg, 1); |
629 | 626 | ||
630 | /* If everything went ok (i.e. 1 msg transmitted), return #bytes | 627 | /* If everything went ok (i.e. 1 msg transmitted), return #bytes |
@@ -757,7 +754,7 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
757 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { | 754 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { |
758 | if (address_data->probe[0] == I2C_CLIENT_END | 755 | if (address_data->probe[0] == I2C_CLIENT_END |
759 | && address_data->normal_i2c[0] == I2C_CLIENT_END) | 756 | && address_data->normal_i2c[0] == I2C_CLIENT_END) |
760 | return 0; | 757 | return 0; |
761 | 758 | ||
762 | dev_warn(&adapter->dev, "SMBus Quick command not supported, " | 759 | dev_warn(&adapter->dev, "SMBus Quick command not supported, " |
763 | "can't probe for chips\n"); | 760 | "can't probe for chips\n"); |
@@ -817,7 +814,7 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
817 | struct i2c_adapter* i2c_get_adapter(int id) | 814 | struct i2c_adapter* i2c_get_adapter(int id) |
818 | { | 815 | { |
819 | struct i2c_adapter *adapter; | 816 | struct i2c_adapter *adapter; |
820 | 817 | ||
821 | mutex_lock(&core_lists); | 818 | mutex_lock(&core_lists); |
822 | adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); | 819 | adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); |
823 | if (adapter && !try_module_get(adapter->owner)) | 820 | if (adapter && !try_module_get(adapter->owner)) |
@@ -834,14 +831,14 @@ void i2c_put_adapter(struct i2c_adapter *adap) | |||
834 | 831 | ||
835 | /* The SMBus parts */ | 832 | /* The SMBus parts */ |
836 | 833 | ||
837 | #define POLY (0x1070U << 3) | 834 | #define POLY (0x1070U << 3) |
838 | static u8 | 835 | static u8 |
839 | crc8(u16 data) | 836 | crc8(u16 data) |
840 | { | 837 | { |
841 | int i; | 838 | int i; |
842 | 839 | ||
843 | for(i = 0; i < 8; i++) { | 840 | for(i = 0; i < 8; i++) { |
844 | if (data & 0x8000) | 841 | if (data & 0x8000) |
845 | data = data ^ POLY; | 842 | data = data ^ POLY; |
846 | data = data << 1; | 843 | data = data << 1; |
847 | } | 844 | } |
@@ -891,13 +888,13 @@ static int i2c_smbus_check_pec(u8 cpec, struct i2c_msg *msg) | |||
891 | rpec, cpec); | 888 | rpec, cpec); |
892 | return -1; | 889 | return -1; |
893 | } | 890 | } |
894 | return 0; | 891 | return 0; |
895 | } | 892 | } |
896 | 893 | ||
897 | s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value) | 894 | s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value) |
898 | { | 895 | { |
899 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 896 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, |
900 | value,0,I2C_SMBUS_QUICK,NULL); | 897 | value,0,I2C_SMBUS_QUICK,NULL); |
901 | } | 898 | } |
902 | 899 | ||
903 | s32 i2c_smbus_read_byte(struct i2c_client *client) | 900 | s32 i2c_smbus_read_byte(struct i2c_client *client) |
@@ -996,11 +993,11 @@ s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command, | |||
996 | I2C_SMBUS_I2C_BLOCK_DATA, &data); | 993 | I2C_SMBUS_I2C_BLOCK_DATA, &data); |
997 | } | 994 | } |
998 | 995 | ||
999 | /* Simulate a SMBus command using the i2c protocol | 996 | /* Simulate a SMBus command using the i2c protocol |
1000 | No checking of parameters is done! */ | 997 | No checking of parameters is done! */ |
1001 | static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | 998 | static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, |
1002 | unsigned short flags, | 999 | unsigned short flags, |
1003 | char read_write, u8 command, int size, | 1000 | char read_write, u8 command, int size, |
1004 | union i2c_smbus_data * data) | 1001 | union i2c_smbus_data * data) |
1005 | { | 1002 | { |
1006 | /* So we need to generate a series of msgs. In the case of writing, we | 1003 | /* So we need to generate a series of msgs. In the case of writing, we |
@@ -1010,7 +1007,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1010 | unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; | 1007 | unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; |
1011 | unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; | 1008 | unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; |
1012 | int num = read_write == I2C_SMBUS_READ?2:1; | 1009 | int num = read_write == I2C_SMBUS_READ?2:1; |
1013 | struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, | 1010 | struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, |
1014 | { addr, flags | I2C_M_RD, 0, msgbuf1 } | 1011 | { addr, flags | I2C_M_RD, 0, msgbuf1 } |
1015 | }; | 1012 | }; |
1016 | int i; | 1013 | int i; |
@@ -1103,14 +1100,14 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1103 | if (i) { | 1100 | if (i) { |
1104 | /* Compute PEC if first message is a write */ | 1101 | /* Compute PEC if first message is a write */ |
1105 | if (!(msg[0].flags & I2C_M_RD)) { | 1102 | if (!(msg[0].flags & I2C_M_RD)) { |
1106 | if (num == 1) /* Write only */ | 1103 | if (num == 1) /* Write only */ |
1107 | i2c_smbus_add_pec(&msg[0]); | 1104 | i2c_smbus_add_pec(&msg[0]); |
1108 | else /* Write followed by read */ | 1105 | else /* Write followed by read */ |
1109 | partial_pec = i2c_smbus_msg_pec(0, &msg[0]); | 1106 | partial_pec = i2c_smbus_msg_pec(0, &msg[0]); |
1110 | } | 1107 | } |
1111 | /* Ask for PEC if last message is a read */ | 1108 | /* Ask for PEC if last message is a read */ |
1112 | if (msg[num-1].flags & I2C_M_RD) | 1109 | if (msg[num-1].flags & I2C_M_RD) |
1113 | msg[num-1].len++; | 1110 | msg[num-1].len++; |
1114 | } | 1111 | } |
1115 | 1112 | ||
1116 | if (i2c_transfer(adapter, msg, num) < 0) | 1113 | if (i2c_transfer(adapter, msg, num) < 0) |
@@ -1130,7 +1127,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1130 | case I2C_SMBUS_BYTE_DATA: | 1127 | case I2C_SMBUS_BYTE_DATA: |
1131 | data->byte = msgbuf1[0]; | 1128 | data->byte = msgbuf1[0]; |
1132 | break; | 1129 | break; |
1133 | case I2C_SMBUS_WORD_DATA: | 1130 | case I2C_SMBUS_WORD_DATA: |
1134 | case I2C_SMBUS_PROC_CALL: | 1131 | case I2C_SMBUS_PROC_CALL: |
1135 | data->word = msgbuf1[0] | (msgbuf1[1] << 8); | 1132 | data->word = msgbuf1[0] | (msgbuf1[1] << 8); |
1136 | break; | 1133 | break; |
@@ -1146,7 +1143,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1146 | 1143 | ||
1147 | 1144 | ||
1148 | s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, | 1145 | s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, |
1149 | char read_write, u8 command, int size, | 1146 | char read_write, u8 command, int size, |
1150 | union i2c_smbus_data * data) | 1147 | union i2c_smbus_data * data) |
1151 | { | 1148 | { |
1152 | s32 res; | 1149 | s32 res; |
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 2e22a2ffa606..ac5bd2a7ca99 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | i2c-dev.c - i2c-bus driver, char device interface | 2 | i2c-dev.c - i2c-bus driver, char device interface |
3 | 3 | ||
4 | Copyright (C) 1995-97 Simon G. Vogl | 4 | Copyright (C) 1995-97 Simon G. Vogl |
5 | Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl> | 5 | Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl> |
@@ -90,6 +90,7 @@ static void return_i2c_dev(struct i2c_dev *i2c_dev) | |||
90 | spin_lock(&i2c_dev_list_lock); | 90 | spin_lock(&i2c_dev_list_lock); |
91 | list_del(&i2c_dev->list); | 91 | list_del(&i2c_dev->list); |
92 | spin_unlock(&i2c_dev_list_lock); | 92 | spin_unlock(&i2c_dev_list_lock); |
93 | kfree(i2c_dev); | ||
93 | } | 94 | } |
94 | 95 | ||
95 | static ssize_t show_adapter_name(struct device *dev, | 96 | static ssize_t show_adapter_name(struct device *dev, |
@@ -172,7 +173,7 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
172 | switch ( cmd ) { | 173 | switch ( cmd ) { |
173 | case I2C_SLAVE: | 174 | case I2C_SLAVE: |
174 | case I2C_SLAVE_FORCE: | 175 | case I2C_SLAVE_FORCE: |
175 | if ((arg > 0x3ff) || | 176 | if ((arg > 0x3ff) || |
176 | (((client->flags & I2C_M_TEN) == 0) && arg > 0x7f)) | 177 | (((client->flags & I2C_M_TEN) == 0) && arg > 0x7f)) |
177 | return -EINVAL; | 178 | return -EINVAL; |
178 | if ((cmd == I2C_SLAVE) && i2c_check_addr(client->adapter,arg)) | 179 | if ((cmd == I2C_SLAVE) && i2c_check_addr(client->adapter,arg)) |
@@ -193,12 +194,11 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
193 | return 0; | 194 | return 0; |
194 | case I2C_FUNCS: | 195 | case I2C_FUNCS: |
195 | funcs = i2c_get_functionality(client->adapter); | 196 | funcs = i2c_get_functionality(client->adapter); |
196 | return (copy_to_user((unsigned long __user *)arg, &funcs, | 197 | return put_user(funcs, (unsigned long __user *)arg); |
197 | sizeof(unsigned long)))?-EFAULT:0; | ||
198 | 198 | ||
199 | case I2C_RDWR: | 199 | case I2C_RDWR: |
200 | if (copy_from_user(&rdwr_arg, | 200 | if (copy_from_user(&rdwr_arg, |
201 | (struct i2c_rdwr_ioctl_data __user *)arg, | 201 | (struct i2c_rdwr_ioctl_data __user *)arg, |
202 | sizeof(rdwr_arg))) | 202 | sizeof(rdwr_arg))) |
203 | return -EFAULT; | 203 | return -EFAULT; |
204 | 204 | ||
@@ -206,9 +206,9 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
206 | * be sent at once */ | 206 | * be sent at once */ |
207 | if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) | 207 | if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) |
208 | return -EINVAL; | 208 | return -EINVAL; |
209 | 209 | ||
210 | rdwr_pa = (struct i2c_msg *) | 210 | rdwr_pa = (struct i2c_msg *) |
211 | kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg), | 211 | kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg), |
212 | GFP_KERNEL); | 212 | GFP_KERNEL); |
213 | 213 | ||
214 | if (rdwr_pa == NULL) return -ENOMEM; | 214 | if (rdwr_pa == NULL) return -ENOMEM; |
@@ -278,9 +278,9 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
278 | (struct i2c_smbus_ioctl_data __user *) arg, | 278 | (struct i2c_smbus_ioctl_data __user *) arg, |
279 | sizeof(struct i2c_smbus_ioctl_data))) | 279 | sizeof(struct i2c_smbus_ioctl_data))) |
280 | return -EFAULT; | 280 | return -EFAULT; |
281 | if ((data_arg.size != I2C_SMBUS_BYTE) && | 281 | if ((data_arg.size != I2C_SMBUS_BYTE) && |
282 | (data_arg.size != I2C_SMBUS_QUICK) && | 282 | (data_arg.size != I2C_SMBUS_QUICK) && |
283 | (data_arg.size != I2C_SMBUS_BYTE_DATA) && | 283 | (data_arg.size != I2C_SMBUS_BYTE_DATA) && |
284 | (data_arg.size != I2C_SMBUS_WORD_DATA) && | 284 | (data_arg.size != I2C_SMBUS_WORD_DATA) && |
285 | (data_arg.size != I2C_SMBUS_PROC_CALL) && | 285 | (data_arg.size != I2C_SMBUS_PROC_CALL) && |
286 | (data_arg.size != I2C_SMBUS_BLOCK_DATA) && | 286 | (data_arg.size != I2C_SMBUS_BLOCK_DATA) && |
@@ -291,11 +291,11 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
291 | data_arg.size); | 291 | data_arg.size); |
292 | return -EINVAL; | 292 | return -EINVAL; |
293 | } | 293 | } |
294 | /* Note that I2C_SMBUS_READ and I2C_SMBUS_WRITE are 0 and 1, | 294 | /* Note that I2C_SMBUS_READ and I2C_SMBUS_WRITE are 0 and 1, |
295 | so the check is valid if size==I2C_SMBUS_QUICK too. */ | 295 | so the check is valid if size==I2C_SMBUS_QUICK too. */ |
296 | if ((data_arg.read_write != I2C_SMBUS_READ) && | 296 | if ((data_arg.read_write != I2C_SMBUS_READ) && |
297 | (data_arg.read_write != I2C_SMBUS_WRITE)) { | 297 | (data_arg.read_write != I2C_SMBUS_WRITE)) { |
298 | dev_dbg(&client->adapter->dev, | 298 | dev_dbg(&client->adapter->dev, |
299 | "read_write out of range (%x) in ioctl I2C_SMBUS.\n", | 299 | "read_write out of range (%x) in ioctl I2C_SMBUS.\n", |
300 | data_arg.read_write); | 300 | data_arg.read_write); |
301 | return -EINVAL; | 301 | return -EINVAL; |
@@ -304,7 +304,7 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
304 | /* Note that command values are always valid! */ | 304 | /* Note that command values are always valid! */ |
305 | 305 | ||
306 | if ((data_arg.size == I2C_SMBUS_QUICK) || | 306 | if ((data_arg.size == I2C_SMBUS_QUICK) || |
307 | ((data_arg.size == I2C_SMBUS_BYTE) && | 307 | ((data_arg.size == I2C_SMBUS_BYTE) && |
308 | (data_arg.read_write == I2C_SMBUS_WRITE))) | 308 | (data_arg.read_write == I2C_SMBUS_WRITE))) |
309 | /* These are special: we do not use data */ | 309 | /* These are special: we do not use data */ |
310 | return i2c_smbus_xfer(client->adapter, client->addr, | 310 | return i2c_smbus_xfer(client->adapter, client->addr, |
@@ -322,14 +322,14 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
322 | if ((data_arg.size == I2C_SMBUS_BYTE_DATA) || | 322 | if ((data_arg.size == I2C_SMBUS_BYTE_DATA) || |
323 | (data_arg.size == I2C_SMBUS_BYTE)) | 323 | (data_arg.size == I2C_SMBUS_BYTE)) |
324 | datasize = sizeof(data_arg.data->byte); | 324 | datasize = sizeof(data_arg.data->byte); |
325 | else if ((data_arg.size == I2C_SMBUS_WORD_DATA) || | 325 | else if ((data_arg.size == I2C_SMBUS_WORD_DATA) || |
326 | (data_arg.size == I2C_SMBUS_PROC_CALL)) | 326 | (data_arg.size == I2C_SMBUS_PROC_CALL)) |
327 | datasize = sizeof(data_arg.data->word); | 327 | datasize = sizeof(data_arg.data->word); |
328 | else /* size == smbus block, i2c block, or block proc. call */ | 328 | else /* size == smbus block, i2c block, or block proc. call */ |
329 | datasize = sizeof(data_arg.data->block); | 329 | datasize = sizeof(data_arg.data->block); |
330 | 330 | ||
331 | if ((data_arg.size == I2C_SMBUS_PROC_CALL) || | 331 | if ((data_arg.size == I2C_SMBUS_PROC_CALL) || |
332 | (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || | 332 | (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || |
333 | (data_arg.read_write == I2C_SMBUS_WRITE)) { | 333 | (data_arg.read_write == I2C_SMBUS_WRITE)) { |
334 | if (copy_from_user(&temp, data_arg.data, datasize)) | 334 | if (copy_from_user(&temp, data_arg.data, datasize)) |
335 | return -EFAULT; | 335 | return -EFAULT; |
@@ -337,8 +337,8 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
337 | res = i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 337 | res = i2c_smbus_xfer(client->adapter,client->addr,client->flags, |
338 | data_arg.read_write, | 338 | data_arg.read_write, |
339 | data_arg.command,data_arg.size,&temp); | 339 | data_arg.command,data_arg.size,&temp); |
340 | if (! res && ((data_arg.size == I2C_SMBUS_PROC_CALL) || | 340 | if (! res && ((data_arg.size == I2C_SMBUS_PROC_CALL) || |
341 | (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || | 341 | (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || |
342 | (data_arg.read_write == I2C_SMBUS_READ))) { | 342 | (data_arg.read_write == I2C_SMBUS_READ))) { |
343 | if (copy_to_user(data_arg.data, &temp, datasize)) | 343 | if (copy_to_user(data_arg.data, &temp, datasize)) |
344 | return -EFAULT; | 344 | return -EFAULT; |
@@ -417,8 +417,8 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) | |||
417 | i2c_dev->dev = device_create(i2c_dev_class, &adap->dev, | 417 | i2c_dev->dev = device_create(i2c_dev_class, &adap->dev, |
418 | MKDEV(I2C_MAJOR, adap->nr), | 418 | MKDEV(I2C_MAJOR, adap->nr), |
419 | "i2c-%d", adap->nr); | 419 | "i2c-%d", adap->nr); |
420 | if (!i2c_dev->dev) { | 420 | if (IS_ERR(i2c_dev->dev)) { |
421 | res = -ENODEV; | 421 | res = PTR_ERR(i2c_dev->dev); |
422 | goto error; | 422 | goto error; |
423 | } | 423 | } |
424 | res = device_create_file(i2c_dev->dev, &dev_attr_name); | 424 | res = device_create_file(i2c_dev->dev, &dev_attr_name); |
@@ -432,7 +432,6 @@ error_destroy: | |||
432 | device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); | 432 | device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); |
433 | error: | 433 | error: |
434 | return_i2c_dev(i2c_dev); | 434 | return_i2c_dev(i2c_dev); |
435 | kfree(i2c_dev); | ||
436 | return res; | 435 | return res; |
437 | } | 436 | } |
438 | 437 | ||
@@ -447,7 +446,6 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap) | |||
447 | device_remove_file(i2c_dev->dev, &dev_attr_name); | 446 | device_remove_file(i2c_dev->dev, &dev_attr_name); |
448 | return_i2c_dev(i2c_dev); | 447 | return_i2c_dev(i2c_dev); |
449 | device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); | 448 | device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); |
450 | kfree(i2c_dev); | ||
451 | 449 | ||
452 | pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); | 450 | pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); |
453 | return 0; | 451 | return 0; |
diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c index 13a617917bf2..fbb7f14ec509 100644 --- a/drivers/ieee1394/pcilynx.c +++ b/drivers/ieee1394/pcilynx.c | |||
@@ -1485,7 +1485,7 @@ static int __devinit add_card(struct pci_dev *dev, | |||
1485 | 1485 | ||
1486 | } | 1486 | } |
1487 | 1487 | ||
1488 | i2c_bit_del_bus(i2c_ad); | 1488 | i2c_del_adapter(i2c_ad); |
1489 | kfree(i2c_ad); | 1489 | kfree(i2c_ad); |
1490 | } | 1490 | } |
1491 | } | 1491 | } |
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c index 8e4ce101eb22..ffda71dfdd65 100644 --- a/drivers/media/dvb/pluto2/pluto2.c +++ b/drivers/media/dvb/pluto2/pluto2.c | |||
@@ -650,7 +650,7 @@ static int __devinit pluto2_probe(struct pci_dev *pdev, | |||
650 | /* dvb */ | 650 | /* dvb */ |
651 | ret = dvb_register_adapter(&pluto->dvb_adapter, DRIVER_NAME, THIS_MODULE, &pdev->dev); | 651 | ret = dvb_register_adapter(&pluto->dvb_adapter, DRIVER_NAME, THIS_MODULE, &pdev->dev); |
652 | if (ret < 0) | 652 | if (ret < 0) |
653 | goto err_i2c_bit_del_bus; | 653 | goto err_i2c_del_adapter; |
654 | 654 | ||
655 | dvb_adapter = &pluto->dvb_adapter; | 655 | dvb_adapter = &pluto->dvb_adapter; |
656 | 656 | ||
@@ -712,8 +712,8 @@ err_dvb_dmx_release: | |||
712 | dvb_dmx_release(dvbdemux); | 712 | dvb_dmx_release(dvbdemux); |
713 | err_dvb_unregister_adapter: | 713 | err_dvb_unregister_adapter: |
714 | dvb_unregister_adapter(dvb_adapter); | 714 | dvb_unregister_adapter(dvb_adapter); |
715 | err_i2c_bit_del_bus: | 715 | err_i2c_del_adapter: |
716 | i2c_bit_del_bus(&pluto->i2c_adap); | 716 | i2c_del_adapter(&pluto->i2c_adap); |
717 | err_pluto_hw_exit: | 717 | err_pluto_hw_exit: |
718 | pluto_hw_exit(pluto); | 718 | pluto_hw_exit(pluto); |
719 | err_free_irq: | 719 | err_free_irq: |
@@ -748,7 +748,7 @@ static void __devexit pluto2_remove(struct pci_dev *pdev) | |||
748 | dvb_dmxdev_release(&pluto->dmxdev); | 748 | dvb_dmxdev_release(&pluto->dmxdev); |
749 | dvb_dmx_release(dvbdemux); | 749 | dvb_dmx_release(dvbdemux); |
750 | dvb_unregister_adapter(dvb_adapter); | 750 | dvb_unregister_adapter(dvb_adapter); |
751 | i2c_bit_del_bus(&pluto->i2c_adap); | 751 | i2c_del_adapter(&pluto->i2c_adap); |
752 | pluto_hw_exit(pluto); | 752 | pluto_hw_exit(pluto); |
753 | free_irq(pdev->irq, pluto); | 753 | free_irq(pdev->irq, pluto); |
754 | pci_iounmap(pdev, pluto->io_mem); | 754 | pci_iounmap(pdev, pluto->io_mem); |
diff --git a/drivers/media/video/bt8xx/bttv-i2c.c b/drivers/media/video/bt8xx/bttv-i2c.c index 70de6c96e201..62b873076e09 100644 --- a/drivers/media/video/bt8xx/bttv-i2c.c +++ b/drivers/media/video/bt8xx/bttv-i2c.c | |||
@@ -479,11 +479,7 @@ int __devexit fini_bttv_i2c(struct bttv *btv) | |||
479 | if (0 != btv->i2c_rc) | 479 | if (0 != btv->i2c_rc) |
480 | return 0; | 480 | return 0; |
481 | 481 | ||
482 | if (btv->use_i2c_hw) { | 482 | return i2c_del_adapter(&btv->c.i2c_adap); |
483 | return i2c_del_adapter(&btv->c.i2c_adap); | ||
484 | } else { | ||
485 | return i2c_bit_del_bus(&btv->c.i2c_adap); | ||
486 | } | ||
487 | } | 483 | } |
488 | 484 | ||
489 | /* | 485 | /* |
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c index 4b655f2ef278..453af5e943ff 100644 --- a/drivers/media/video/cx88/cx88-core.c +++ b/drivers/media/video/cx88/cx88-core.c | |||
@@ -1153,7 +1153,7 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci) | |||
1153 | mutex_lock(&devlist); | 1153 | mutex_lock(&devlist); |
1154 | cx88_ir_fini(core); | 1154 | cx88_ir_fini(core); |
1155 | if (0 == core->i2c_rc) | 1155 | if (0 == core->i2c_rc) |
1156 | i2c_bit_del_bus(&core->i2c_adap); | 1156 | i2c_del_adapter(&core->i2c_adap); |
1157 | list_del(&core->devlist); | 1157 | list_del(&core->devlist); |
1158 | iounmap(core->lmmio); | 1158 | iounmap(core->lmmio); |
1159 | cx88_devcount--; | 1159 | cx88_devcount--; |
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.c b/drivers/media/video/cx88/cx88-vp3054-i2c.c index 2b4f1970c7df..6068c9bf82cd 100644 --- a/drivers/media/video/cx88/cx88-vp3054-i2c.c +++ b/drivers/media/video/cx88/cx88-vp3054-i2c.c | |||
@@ -168,7 +168,7 @@ void vp3054_i2c_remove(struct cx8802_dev *dev) | |||
168 | dev->core->board != CX88_BOARD_DNTV_LIVE_DVB_T_PRO) | 168 | dev->core->board != CX88_BOARD_DNTV_LIVE_DVB_T_PRO) |
169 | return; | 169 | return; |
170 | 170 | ||
171 | i2c_bit_del_bus(&vp3054_i2c->adap); | 171 | i2c_del_adapter(&vp3054_i2c->adap); |
172 | kfree(vp3054_i2c); | 172 | kfree(vp3054_i2c); |
173 | } | 173 | } |
174 | 174 | ||
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c index 6b6dff4d236a..a373c142e742 100644 --- a/drivers/media/video/vino.c +++ b/drivers/media/video/vino.c | |||
@@ -782,7 +782,7 @@ static int vino_i2c_add_bus(void) | |||
782 | 782 | ||
783 | static int vino_i2c_del_bus(void) | 783 | static int vino_i2c_del_bus(void) |
784 | { | 784 | { |
785 | return i2c_sgi_del_bus(&vino_i2c_adapter); | 785 | return i2c_del_adapter(&vino_i2c_adapter); |
786 | } | 786 | } |
787 | 787 | ||
788 | static int i2c_camera_command(unsigned int cmd, void *arg) | 788 | static int i2c_camera_command(unsigned int cmd, void *arg) |
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c index 653822ce391c..4d1eb2fba34a 100644 --- a/drivers/media/video/zoran_card.c +++ b/drivers/media/video/zoran_card.c | |||
@@ -849,7 +849,7 @@ zoran_register_i2c (struct zoran *zr) | |||
849 | static void | 849 | static void |
850 | zoran_unregister_i2c (struct zoran *zr) | 850 | zoran_unregister_i2c (struct zoran *zr) |
851 | { | 851 | { |
852 | i2c_bit_del_bus((&zr->i2c_adapter)); | 852 | i2c_del_adapter(&zr->i2c_adapter); |
853 | } | 853 | } |
854 | 854 | ||
855 | /* Check a zoran_params struct for correctness, insert default params */ | 855 | /* Check a zoran_params struct for correctness, insert default params */ |
diff --git a/drivers/video/aty/radeon_i2c.c b/drivers/video/aty/radeon_i2c.c index 869725a13c21..e7c5b219ad1b 100644 --- a/drivers/video/aty/radeon_i2c.c +++ b/drivers/video/aty/radeon_i2c.c | |||
@@ -120,19 +120,19 @@ void radeon_create_i2c_busses(struct radeonfb_info *rinfo) | |||
120 | void radeon_delete_i2c_busses(struct radeonfb_info *rinfo) | 120 | void radeon_delete_i2c_busses(struct radeonfb_info *rinfo) |
121 | { | 121 | { |
122 | if (rinfo->i2c[0].rinfo) | 122 | if (rinfo->i2c[0].rinfo) |
123 | i2c_bit_del_bus(&rinfo->i2c[0].adapter); | 123 | i2c_del_adapter(&rinfo->i2c[0].adapter); |
124 | rinfo->i2c[0].rinfo = NULL; | 124 | rinfo->i2c[0].rinfo = NULL; |
125 | 125 | ||
126 | if (rinfo->i2c[1].rinfo) | 126 | if (rinfo->i2c[1].rinfo) |
127 | i2c_bit_del_bus(&rinfo->i2c[1].adapter); | 127 | i2c_del_adapter(&rinfo->i2c[1].adapter); |
128 | rinfo->i2c[1].rinfo = NULL; | 128 | rinfo->i2c[1].rinfo = NULL; |
129 | 129 | ||
130 | if (rinfo->i2c[2].rinfo) | 130 | if (rinfo->i2c[2].rinfo) |
131 | i2c_bit_del_bus(&rinfo->i2c[2].adapter); | 131 | i2c_del_adapter(&rinfo->i2c[2].adapter); |
132 | rinfo->i2c[2].rinfo = NULL; | 132 | rinfo->i2c[2].rinfo = NULL; |
133 | 133 | ||
134 | if (rinfo->i2c[3].rinfo) | 134 | if (rinfo->i2c[3].rinfo) |
135 | i2c_bit_del_bus(&rinfo->i2c[3].adapter); | 135 | i2c_del_adapter(&rinfo->i2c[3].adapter); |
136 | rinfo->i2c[3].rinfo = NULL; | 136 | rinfo->i2c[3].rinfo = NULL; |
137 | } | 137 | } |
138 | 138 | ||
diff --git a/drivers/video/i810/i810-i2c.c b/drivers/video/i810/i810-i2c.c index b952e4504abe..961f4d404467 100644 --- a/drivers/video/i810/i810-i2c.c +++ b/drivers/video/i810/i810-i2c.c | |||
@@ -137,15 +137,15 @@ void i810_create_i2c_busses(struct i810fb_par *par) | |||
137 | void i810_delete_i2c_busses(struct i810fb_par *par) | 137 | void i810_delete_i2c_busses(struct i810fb_par *par) |
138 | { | 138 | { |
139 | if (par->chan[0].par) | 139 | if (par->chan[0].par) |
140 | i2c_bit_del_bus(&par->chan[0].adapter); | 140 | i2c_del_adapter(&par->chan[0].adapter); |
141 | par->chan[0].par = NULL; | 141 | par->chan[0].par = NULL; |
142 | 142 | ||
143 | if (par->chan[1].par) | 143 | if (par->chan[1].par) |
144 | i2c_bit_del_bus(&par->chan[1].adapter); | 144 | i2c_del_adapter(&par->chan[1].adapter); |
145 | par->chan[1].par = NULL; | 145 | par->chan[1].par = NULL; |
146 | 146 | ||
147 | if (par->chan[2].par) | 147 | if (par->chan[2].par) |
148 | i2c_bit_del_bus(&par->chan[2].adapter); | 148 | i2c_del_adapter(&par->chan[2].adapter); |
149 | par->chan[2].par = NULL; | 149 | par->chan[2].par = NULL; |
150 | } | 150 | } |
151 | 151 | ||
diff --git a/drivers/video/intelfb/intelfb_i2c.c b/drivers/video/intelfb/intelfb_i2c.c index 5686e2164e39..33bc41f50540 100644 --- a/drivers/video/intelfb/intelfb_i2c.c +++ b/drivers/video/intelfb/intelfb_i2c.c | |||
@@ -188,11 +188,11 @@ void intelfb_delete_i2c_busses(struct intelfb_info *dinfo) | |||
188 | 188 | ||
189 | for (i = 0; i < MAX_OUTPUTS; i++) { | 189 | for (i = 0; i < MAX_OUTPUTS; i++) { |
190 | if (dinfo->output[i].i2c_bus.dinfo) { | 190 | if (dinfo->output[i].i2c_bus.dinfo) { |
191 | i2c_bit_del_bus(&dinfo->output[i].i2c_bus.adapter); | 191 | i2c_del_adapter(&dinfo->output[i].i2c_bus.adapter); |
192 | dinfo->output[i].i2c_bus.dinfo = NULL; | 192 | dinfo->output[i].i2c_bus.dinfo = NULL; |
193 | } | 193 | } |
194 | if (dinfo->output[i].ddc_bus.dinfo) { | 194 | if (dinfo->output[i].ddc_bus.dinfo) { |
195 | i2c_bit_del_bus(&dinfo->output[i].ddc_bus.adapter); | 195 | i2c_del_adapter(&dinfo->output[i].ddc_bus.adapter); |
196 | dinfo->output[i].ddc_bus.dinfo = NULL; | 196 | dinfo->output[i].ddc_bus.dinfo = NULL; |
197 | } | 197 | } |
198 | } | 198 | } |
diff --git a/drivers/video/matrox/i2c-matroxfb.c b/drivers/video/matrox/i2c-matroxfb.c index 795c1a99a680..797b42305b0f 100644 --- a/drivers/video/matrox/i2c-matroxfb.c +++ b/drivers/video/matrox/i2c-matroxfb.c | |||
@@ -124,7 +124,7 @@ static int i2c_bus_reg(struct i2c_bit_adapter* b, struct matrox_fb_info* minfo, | |||
124 | 124 | ||
125 | static void i2c_bit_bus_del(struct i2c_bit_adapter* b) { | 125 | static void i2c_bit_bus_del(struct i2c_bit_adapter* b) { |
126 | if (b->initialized) { | 126 | if (b->initialized) { |
127 | i2c_bit_del_bus(&b->adapter); | 127 | i2c_del_adapter(&b->adapter); |
128 | b->initialized = 0; | 128 | b->initialized = 0; |
129 | } | 129 | } |
130 | } | 130 | } |
diff --git a/drivers/video/nvidia/nv_i2c.c b/drivers/video/nvidia/nv_i2c.c index 442e85328341..8454adf2d178 100644 --- a/drivers/video/nvidia/nv_i2c.c +++ b/drivers/video/nvidia/nv_i2c.c | |||
@@ -147,15 +147,15 @@ void nvidia_create_i2c_busses(struct nvidia_par *par) | |||
147 | void nvidia_delete_i2c_busses(struct nvidia_par *par) | 147 | void nvidia_delete_i2c_busses(struct nvidia_par *par) |
148 | { | 148 | { |
149 | if (par->chan[0].par) | 149 | if (par->chan[0].par) |
150 | i2c_bit_del_bus(&par->chan[0].adapter); | 150 | i2c_del_adapter(&par->chan[0].adapter); |
151 | par->chan[0].par = NULL; | 151 | par->chan[0].par = NULL; |
152 | 152 | ||
153 | if (par->chan[1].par) | 153 | if (par->chan[1].par) |
154 | i2c_bit_del_bus(&par->chan[1].adapter); | 154 | i2c_del_adapter(&par->chan[1].adapter); |
155 | par->chan[1].par = NULL; | 155 | par->chan[1].par = NULL; |
156 | 156 | ||
157 | if (par->chan[2].par) | 157 | if (par->chan[2].par) |
158 | i2c_bit_del_bus(&par->chan[2].adapter); | 158 | i2c_del_adapter(&par->chan[2].adapter); |
159 | par->chan[2].par = NULL; | 159 | par->chan[2].par = NULL; |
160 | 160 | ||
161 | } | 161 | } |
diff --git a/drivers/video/riva/rivafb-i2c.c b/drivers/video/riva/rivafb-i2c.c index c15b259af644..01b85e3b0ae1 100644 --- a/drivers/video/riva/rivafb-i2c.c +++ b/drivers/video/riva/rivafb-i2c.c | |||
@@ -144,15 +144,15 @@ void riva_create_i2c_busses(struct riva_par *par) | |||
144 | void riva_delete_i2c_busses(struct riva_par *par) | 144 | void riva_delete_i2c_busses(struct riva_par *par) |
145 | { | 145 | { |
146 | if (par->chan[0].par) | 146 | if (par->chan[0].par) |
147 | i2c_bit_del_bus(&par->chan[0].adapter); | 147 | i2c_del_adapter(&par->chan[0].adapter); |
148 | par->chan[0].par = NULL; | 148 | par->chan[0].par = NULL; |
149 | 149 | ||
150 | if (par->chan[1].par) | 150 | if (par->chan[1].par) |
151 | i2c_bit_del_bus(&par->chan[1].adapter); | 151 | i2c_del_adapter(&par->chan[1].adapter); |
152 | par->chan[1].par = NULL; | 152 | par->chan[1].par = NULL; |
153 | 153 | ||
154 | if (par->chan[2].par) | 154 | if (par->chan[2].par) |
155 | i2c_bit_del_bus(&par->chan[2].adapter); | 155 | i2c_del_adapter(&par->chan[2].adapter); |
156 | par->chan[2].par = NULL; | 156 | par->chan[2].par = NULL; |
157 | } | 157 | } |
158 | 158 | ||
diff --git a/drivers/video/savage/savagefb-i2c.c b/drivers/video/savage/savagefb-i2c.c index cef5bf591cdf..1411f3b6a009 100644 --- a/drivers/video/savage/savagefb-i2c.c +++ b/drivers/video/savage/savagefb-i2c.c | |||
@@ -208,7 +208,7 @@ void savagefb_delete_i2c_busses(struct fb_info *info) | |||
208 | struct savagefb_par *par = info->par; | 208 | struct savagefb_par *par = info->par; |
209 | 209 | ||
210 | if (par->chan.par) | 210 | if (par->chan.par) |
211 | i2c_bit_del_bus(&par->chan.adapter); | 211 | i2c_del_adapter(&par->chan.adapter); |
212 | 212 | ||
213 | par->chan.par = NULL; | 213 | par->chan.par = NULL; |
214 | } | 214 | } |
diff --git a/include/asm-arm/arch-pnx4008/i2c.h b/include/asm-arm/arch-pnx4008/i2c.h new file mode 100644 index 000000000000..92e8d65006f7 --- /dev/null +++ b/include/asm-arm/arch-pnx4008/i2c.h | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * PNX4008-specific tweaks for I2C IP3204 block | ||
3 | * | ||
4 | * Author: Vitaly Wool <vwool@ru.mvista.com> | ||
5 | * | ||
6 | * 2005 (c) MontaVista Software, Inc. This file is licensed under | ||
7 | * the terms of the GNU General Public License version 2. This program | ||
8 | * is licensed "as is" without any warranty of any kind, whether express | ||
9 | * or implied. | ||
10 | */ | ||
11 | |||
12 | #ifndef __ASM_ARCH_I2C_H__ | ||
13 | #define __ASM_ARCH_I2C_H__ | ||
14 | |||
15 | #include <linux/pm.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | |||
18 | enum { | ||
19 | mstatus_tdi = 0x00000001, | ||
20 | mstatus_afi = 0x00000002, | ||
21 | mstatus_nai = 0x00000004, | ||
22 | mstatus_drmi = 0x00000008, | ||
23 | mstatus_active = 0x00000020, | ||
24 | mstatus_scl = 0x00000040, | ||
25 | mstatus_sda = 0x00000080, | ||
26 | mstatus_rff = 0x00000100, | ||
27 | mstatus_rfe = 0x00000200, | ||
28 | mstatus_tff = 0x00000400, | ||
29 | mstatus_tfe = 0x00000800, | ||
30 | }; | ||
31 | |||
32 | enum { | ||
33 | mcntrl_tdie = 0x00000001, | ||
34 | mcntrl_afie = 0x00000002, | ||
35 | mcntrl_naie = 0x00000004, | ||
36 | mcntrl_drmie = 0x00000008, | ||
37 | mcntrl_daie = 0x00000020, | ||
38 | mcntrl_rffie = 0x00000040, | ||
39 | mcntrl_tffie = 0x00000080, | ||
40 | mcntrl_reset = 0x00000100, | ||
41 | mcntrl_cdbmode = 0x00000400, | ||
42 | }; | ||
43 | |||
44 | enum { | ||
45 | rw_bit = 1 << 0, | ||
46 | start_bit = 1 << 8, | ||
47 | stop_bit = 1 << 9, | ||
48 | }; | ||
49 | |||
50 | #define I2C_REG_RX(a) ((a)->ioaddr) /* Rx FIFO reg (RO) */ | ||
51 | #define I2C_REG_TX(a) ((a)->ioaddr) /* Tx FIFO reg (WO) */ | ||
52 | #define I2C_REG_STS(a) ((a)->ioaddr + 0x04) /* Status reg (RO) */ | ||
53 | #define I2C_REG_CTL(a) ((a)->ioaddr + 0x08) /* Ctl reg */ | ||
54 | #define I2C_REG_CKL(a) ((a)->ioaddr + 0x0c) /* Clock divider low */ | ||
55 | #define I2C_REG_CKH(a) ((a)->ioaddr + 0x10) /* Clock divider high */ | ||
56 | #define I2C_REG_ADR(a) ((a)->ioaddr + 0x14) /* I2C address */ | ||
57 | #define I2C_REG_RFL(a) ((a)->ioaddr + 0x18) /* Rx FIFO level (RO) */ | ||
58 | #define I2C_REG_TFL(a) ((a)->ioaddr + 0x1c) /* Tx FIFO level (RO) */ | ||
59 | #define I2C_REG_RXB(a) ((a)->ioaddr + 0x20) /* Num of bytes Rx-ed (RO) */ | ||
60 | #define I2C_REG_TXB(a) ((a)->ioaddr + 0x24) /* Num of bytes Tx-ed (RO) */ | ||
61 | #define I2C_REG_TXS(a) ((a)->ioaddr + 0x28) /* Tx slave FIFO (RO) */ | ||
62 | #define I2C_REG_STFL(a) ((a)->ioaddr + 0x2c) /* Tx slave FIFO level (RO) */ | ||
63 | |||
64 | #define HCLK_MHZ 13 | ||
65 | #define I2C_CHIP_NAME "PNX4008-I2C" | ||
66 | |||
67 | #endif /* __ASM_ARCH_I2C_H___ */ | ||
diff --git a/include/linux/i2c-algo-bit.h b/include/linux/i2c-algo-bit.h index c8f8df25c7e0..937da70cb4c4 100644 --- a/include/linux/i2c-algo-bit.h +++ b/include/linux/i2c-algo-bit.h | |||
@@ -26,9 +26,9 @@ | |||
26 | 26 | ||
27 | /* --- Defines for bit-adapters --------------------------------------- */ | 27 | /* --- Defines for bit-adapters --------------------------------------- */ |
28 | /* | 28 | /* |
29 | * This struct contains the hw-dependent functions of bit-style adapters to | 29 | * This struct contains the hw-dependent functions of bit-style adapters to |
30 | * manipulate the line states, and to init any hw-specific features. This is | 30 | * manipulate the line states, and to init any hw-specific features. This is |
31 | * only used if you have more than one hw-type of adapter running. | 31 | * only used if you have more than one hw-type of adapter running. |
32 | */ | 32 | */ |
33 | struct i2c_algo_bit_data { | 33 | struct i2c_algo_bit_data { |
34 | void *data; /* private data for lowlevel routines */ | 34 | void *data; /* private data for lowlevel routines */ |
@@ -44,6 +44,5 @@ struct i2c_algo_bit_data { | |||
44 | }; | 44 | }; |
45 | 45 | ||
46 | int i2c_bit_add_bus(struct i2c_adapter *); | 46 | int i2c_bit_add_bus(struct i2c_adapter *); |
47 | int i2c_bit_del_bus(struct i2c_adapter *); | ||
48 | 47 | ||
49 | #endif /* _LINUX_I2C_ALGO_BIT_H */ | 48 | #endif /* _LINUX_I2C_ALGO_BIT_H */ |
diff --git a/include/linux/i2c-algo-ite.h b/include/linux/i2c-algo-ite.h deleted file mode 100644 index 0073fe96c76e..000000000000 --- a/include/linux/i2c-algo-ite.h +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | /* ------------------------------------------------------------------------- */ | ||
2 | /* i2c-algo-ite.h i2c driver algorithms for ITE IIC adapters */ | ||
3 | /* ------------------------------------------------------------------------- */ | ||
4 | /* Copyright (C) 1995-97 Simon G. Vogl | ||
5 | 1998-99 Hans Berglund | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
20 | /* ------------------------------------------------------------------------- */ | ||
21 | |||
22 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even | ||
23 | Frodo Looijaard <frodol@dds.nl> */ | ||
24 | |||
25 | /* Modifications by MontaVista Software, 2001 | ||
26 | Changes made to support the ITE IIC peripheral */ | ||
27 | |||
28 | |||
29 | #ifndef I2C_ALGO_ITE_H | ||
30 | #define I2C_ALGO_ITE_H 1 | ||
31 | |||
32 | #include <linux/types.h> | ||
33 | |||
34 | /* Example of a sequential read request: | ||
35 | struct i2c_iic_msg s_msg; | ||
36 | |||
37 | s_msg.addr=device_address; | ||
38 | s_msg.len=length; | ||
39 | s_msg.buf=buffer; | ||
40 | s_msg.waddr=word_address; | ||
41 | ioctl(file,I2C_SREAD, &s_msg); | ||
42 | */ | ||
43 | #define I2C_SREAD 0x780 /* SREAD ioctl command */ | ||
44 | |||
45 | struct i2c_iic_msg { | ||
46 | __u16 addr; /* device address */ | ||
47 | __u16 waddr; /* word address */ | ||
48 | short len; /* msg length */ | ||
49 | char *buf; /* pointer to msg data */ | ||
50 | }; | ||
51 | |||
52 | #ifdef __KERNEL__ | ||
53 | struct i2c_adapter; | ||
54 | |||
55 | struct i2c_algo_iic_data { | ||
56 | void *data; /* private data for lolevel routines */ | ||
57 | void (*setiic) (void *data, int ctl, int val); | ||
58 | int (*getiic) (void *data, int ctl); | ||
59 | int (*getown) (void *data); | ||
60 | int (*getclock) (void *data); | ||
61 | void (*waitforpin) (void); | ||
62 | |||
63 | /* local settings */ | ||
64 | int udelay; | ||
65 | int mdelay; | ||
66 | int timeout; | ||
67 | }; | ||
68 | |||
69 | int i2c_iic_add_bus(struct i2c_adapter *); | ||
70 | int i2c_iic_del_bus(struct i2c_adapter *); | ||
71 | #endif /* __KERNEL__ */ | ||
72 | #endif /* I2C_ALGO_ITE_H */ | ||
diff --git a/include/linux/i2c-algo-pca.h b/include/linux/i2c-algo-pca.h index 226693e0d88b..fce47c051bb1 100644 --- a/include/linux/i2c-algo-pca.h +++ b/include/linux/i2c-algo-pca.h | |||
@@ -10,6 +10,5 @@ struct i2c_algo_pca_data { | |||
10 | }; | 10 | }; |
11 | 11 | ||
12 | int i2c_pca_add_bus(struct i2c_adapter *); | 12 | int i2c_pca_add_bus(struct i2c_adapter *); |
13 | int i2c_pca_del_bus(struct i2c_adapter *); | ||
14 | 13 | ||
15 | #endif /* _LINUX_I2C_ALGO_PCA_H */ | 14 | #endif /* _LINUX_I2C_ALGO_PCA_H */ |
diff --git a/include/linux/i2c-algo-pcf.h b/include/linux/i2c-algo-pcf.h index 9908f3fc4839..994eb86f882c 100644 --- a/include/linux/i2c-algo-pcf.h +++ b/include/linux/i2c-algo-pcf.h | |||
@@ -31,7 +31,7 @@ struct i2c_algo_pcf_data { | |||
31 | int (*getpcf) (void *data, int ctl); | 31 | int (*getpcf) (void *data, int ctl); |
32 | int (*getown) (void *data); | 32 | int (*getown) (void *data); |
33 | int (*getclock) (void *data); | 33 | int (*getclock) (void *data); |
34 | void (*waitforpin) (void); | 34 | void (*waitforpin) (void); |
35 | 35 | ||
36 | /* local settings */ | 36 | /* local settings */ |
37 | int udelay; | 37 | int udelay; |
@@ -39,6 +39,5 @@ struct i2c_algo_pcf_data { | |||
39 | }; | 39 | }; |
40 | 40 | ||
41 | int i2c_pcf_add_bus(struct i2c_adapter *); | 41 | int i2c_pcf_add_bus(struct i2c_adapter *); |
42 | int i2c_pcf_del_bus(struct i2c_adapter *); | ||
43 | 42 | ||
44 | #endif /* _LINUX_I2C_ALGO_PCF_H */ | 43 | #endif /* _LINUX_I2C_ALGO_PCF_H */ |
diff --git a/include/linux/i2c-algo-sgi.h b/include/linux/i2c-algo-sgi.h index 4a0113d64064..3b7715024e69 100644 --- a/include/linux/i2c-algo-sgi.h +++ b/include/linux/i2c-algo-sgi.h | |||
@@ -22,6 +22,5 @@ struct i2c_algo_sgi_data { | |||
22 | }; | 22 | }; |
23 | 23 | ||
24 | int i2c_sgi_add_bus(struct i2c_adapter *); | 24 | int i2c_sgi_add_bus(struct i2c_adapter *); |
25 | int i2c_sgi_del_bus(struct i2c_adapter *); | ||
26 | 25 | ||
27 | #endif /* I2C_ALGO_SGI_H */ | 26 | #endif /* I2C_ALGO_SGI_H */ |
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 0f4cf34b6fa2..7ae3c3326643 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* ------------------------------------------------------------------------- */ | 1 | /* ------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* i2c-id.h - identifier values for i2c drivers and adapters */ | 3 | /* i2c-id.h - identifier values for i2c drivers and adapters */ |
4 | /* */ | 4 | /* */ |
5 | /* ------------------------------------------------------------------------- */ | 5 | /* ------------------------------------------------------------------------- */ |
6 | /* Copyright (C) 1995-1999 Simon G. Vogl | 6 | /* Copyright (C) 1995-1999 Simon G. Vogl |
7 | 7 | ||
@@ -40,10 +40,10 @@ | |||
40 | #define I2C_DRIVERID_SAA7120 11 /* video encoder */ | 40 | #define I2C_DRIVERID_SAA7120 11 /* video encoder */ |
41 | #define I2C_DRIVERID_SAA7121 12 /* video encoder */ | 41 | #define I2C_DRIVERID_SAA7121 12 /* video encoder */ |
42 | #define I2C_DRIVERID_SAA7185B 13 /* video encoder */ | 42 | #define I2C_DRIVERID_SAA7185B 13 /* video encoder */ |
43 | #define I2C_DRIVERID_CH7003 14 /* digital pc to tv encoder */ | 43 | #define I2C_DRIVERID_CH7003 14 /* digital pc to tv encoder */ |
44 | #define I2C_DRIVERID_PCF8574A 15 /* i2c expander - 8 bit in/out */ | 44 | #define I2C_DRIVERID_PCF8574A 15 /* i2c expander - 8 bit in/out */ |
45 | #define I2C_DRIVERID_PCF8582C 16 /* eeprom */ | 45 | #define I2C_DRIVERID_PCF8582C 16 /* eeprom */ |
46 | #define I2C_DRIVERID_AT24Cxx 17 /* eeprom 1/2/4/8/16 K */ | 46 | #define I2C_DRIVERID_AT24Cxx 17 /* eeprom 1/2/4/8/16 K */ |
47 | #define I2C_DRIVERID_TEA6300 18 /* audio mixer */ | 47 | #define I2C_DRIVERID_TEA6300 18 /* audio mixer */ |
48 | #define I2C_DRIVERID_BT829 19 /* pc to tv encoder */ | 48 | #define I2C_DRIVERID_BT829 19 /* pc to tv encoder */ |
49 | #define I2C_DRIVERID_TDA9850 20 /* audio mixer */ | 49 | #define I2C_DRIVERID_TDA9850 20 /* audio mixer */ |
@@ -82,9 +82,8 @@ | |||
82 | #define I2C_DRIVERID_STM41T00 52 /* real time clock */ | 82 | #define I2C_DRIVERID_STM41T00 52 /* real time clock */ |
83 | #define I2C_DRIVERID_UDA1342 53 /* UDA1342 audio codec */ | 83 | #define I2C_DRIVERID_UDA1342 53 /* UDA1342 audio codec */ |
84 | #define I2C_DRIVERID_ADV7170 54 /* video encoder */ | 84 | #define I2C_DRIVERID_ADV7170 54 /* video encoder */ |
85 | #define I2C_DRIVERID_RADEON 55 /* I2C bus on Radeon boards */ | ||
86 | #define I2C_DRIVERID_MAX1617 56 /* temp sensor */ | 85 | #define I2C_DRIVERID_MAX1617 56 /* temp sensor */ |
87 | #define I2C_DRIVERID_SAA7191 57 /* video encoder */ | 86 | #define I2C_DRIVERID_SAA7191 57 /* video decoder */ |
88 | #define I2C_DRIVERID_INDYCAM 58 /* SGI IndyCam */ | 87 | #define I2C_DRIVERID_INDYCAM 58 /* SGI IndyCam */ |
89 | #define I2C_DRIVERID_BT832 59 /* CMOS camera video processor */ | 88 | #define I2C_DRIVERID_BT832 59 /* CMOS camera video processor */ |
90 | #define I2C_DRIVERID_TDA9887 60 /* TDA988x IF-PLL demodulator */ | 89 | #define I2C_DRIVERID_TDA9887 60 /* TDA988x IF-PLL demodulator */ |
@@ -132,7 +131,6 @@ | |||
132 | #define I2C_DRIVERID_ADM1021 1008 | 131 | #define I2C_DRIVERID_ADM1021 1008 |
133 | #define I2C_DRIVERID_ADM9240 1009 | 132 | #define I2C_DRIVERID_ADM9240 1009 |
134 | #define I2C_DRIVERID_LTC1710 1010 | 133 | #define I2C_DRIVERID_LTC1710 1010 |
135 | #define I2C_DRIVERID_ICSPLL 1012 | ||
136 | #define I2C_DRIVERID_BT869 1013 | 134 | #define I2C_DRIVERID_BT869 1013 |
137 | #define I2C_DRIVERID_MAXILIFE 1014 | 135 | #define I2C_DRIVERID_MAXILIFE 1014 |
138 | #define I2C_DRIVERID_MATORB 1015 | 136 | #define I2C_DRIVERID_MATORB 1015 |
@@ -165,7 +163,7 @@ | |||
165 | * ---- Adapter types ---------------------------------------------------- | 163 | * ---- Adapter types ---------------------------------------------------- |
166 | */ | 164 | */ |
167 | 165 | ||
168 | /* --- Bit algorithm adapters */ | 166 | /* --- Bit algorithm adapters */ |
169 | #define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */ | 167 | #define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */ |
170 | #define I2C_HW_B_SER 0x010002 /* Serial line interface */ | 168 | #define I2C_HW_B_SER 0x010002 /* Serial line interface */ |
171 | #define I2C_HW_B_BT848 0x010005 /* BT848 video boards */ | 169 | #define I2C_HW_B_BT848 0x010005 /* BT848 video boards */ |
@@ -213,9 +211,6 @@ | |||
213 | /* --- MPC8xx PowerPC adapters */ | 211 | /* --- MPC8xx PowerPC adapters */ |
214 | #define I2C_HW_MPC8XX_EPON 0x110000 /* Eponymous MPC8xx I2C adapter */ | 212 | #define I2C_HW_MPC8XX_EPON 0x110000 /* Eponymous MPC8xx I2C adapter */ |
215 | 213 | ||
216 | /* --- ITE based algorithms */ | ||
217 | #define I2C_HW_I_IIC 0x080000 /* controller on the ITE */ | ||
218 | |||
219 | /* --- PowerPC on-chip adapters */ | 214 | /* --- PowerPC on-chip adapters */ |
220 | #define I2C_HW_OCP 0x120000 /* IBM on-chip I2C adapter */ | 215 | #define I2C_HW_OCP 0x120000 /* IBM on-chip I2C adapter */ |
221 | 216 | ||
diff --git a/include/linux/i2c-pnx.h b/include/linux/i2c-pnx.h new file mode 100644 index 000000000000..e6e9c814da61 --- /dev/null +++ b/include/linux/i2c-pnx.h | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * Header file for I2C support on PNX010x/4008. | ||
3 | * | ||
4 | * Author: Dennis Kovalev <dkovalev@ru.mvista.com> | ||
5 | * | ||
6 | * 2004-2006 (c) MontaVista Software, Inc. This file is licensed under | ||
7 | * the terms of the GNU General Public License version 2. This program | ||
8 | * is licensed "as is" without any warranty of any kind, whether express | ||
9 | * or implied. | ||
10 | */ | ||
11 | |||
12 | #ifndef __I2C_PNX_H__ | ||
13 | #define __I2C_PNX_H__ | ||
14 | |||
15 | #include <asm/arch/i2c.h> | ||
16 | |||
17 | struct i2c_pnx_mif { | ||
18 | int ret; /* Return value */ | ||
19 | int mode; /* Interface mode */ | ||
20 | struct completion complete; /* I/O completion */ | ||
21 | struct timer_list timer; /* Timeout */ | ||
22 | char * buf; /* Data buffer */ | ||
23 | int len; /* Length of data buffer */ | ||
24 | }; | ||
25 | |||
26 | struct i2c_pnx_algo_data { | ||
27 | u32 base; | ||
28 | u32 ioaddr; | ||
29 | int irq; | ||
30 | struct i2c_pnx_mif mif; | ||
31 | int last; | ||
32 | }; | ||
33 | |||
34 | struct i2c_pnx_data { | ||
35 | int (*suspend) (struct platform_device *pdev, pm_message_t state); | ||
36 | int (*resume) (struct platform_device *pdev); | ||
37 | u32 (*calculate_input_freq) (struct platform_device *pdev); | ||
38 | int (*set_clock_run) (struct platform_device *pdev); | ||
39 | int (*set_clock_stop) (struct platform_device *pdev); | ||
40 | struct i2c_adapter *adapter; | ||
41 | }; | ||
42 | |||
43 | #endif /* __I2C_PNX_H__ */ | ||
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 9b5d04768c2c..71e50d3e492f 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* ------------------------------------------------------------------------- */ | 1 | /* ------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* i2c.h - definitions for the i2c-bus interface */ | 3 | /* i2c.h - definitions for the i2c-bus interface */ |
4 | /* */ | 4 | /* */ |
5 | /* ------------------------------------------------------------------------- */ | 5 | /* ------------------------------------------------------------------------- */ |
6 | /* Copyright (C) 1995-2000 Simon G. Vogl | 6 | /* Copyright (C) 1995-2000 Simon G. Vogl |
7 | 7 | ||
@@ -27,7 +27,7 @@ | |||
27 | #define _LINUX_I2C_H | 27 | #define _LINUX_I2C_H |
28 | 28 | ||
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #ifdef __KERNEL__ | 30 | #ifdef __KERNEL__ |
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/i2c-id.h> | 32 | #include <linux/i2c-id.h> |
33 | #include <linux/mod_devicetable.h> | 33 | #include <linux/mod_devicetable.h> |
@@ -53,8 +53,8 @@ union i2c_smbus_data; | |||
53 | 53 | ||
54 | /* | 54 | /* |
55 | * The master routines are the ones normally used to transmit data to devices | 55 | * The master routines are the ones normally used to transmit data to devices |
56 | * on a bus (or read from them). Apart from two basic transfer functions to | 56 | * on a bus (or read from them). Apart from two basic transfer functions to |
57 | * transmit one message at a time, a more complex version can be used to | 57 | * transmit one message at a time, a more complex version can be used to |
58 | * transmit an arbitrary number of messages without interruption. | 58 | * transmit an arbitrary number of messages without interruption. |
59 | */ | 59 | */ |
60 | extern int i2c_master_send(struct i2c_client *,const char* ,int); | 60 | extern int i2c_master_send(struct i2c_client *,const char* ,int); |
@@ -67,10 +67,10 @@ extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | |||
67 | 67 | ||
68 | /* This is the very generalized SMBus access routine. You probably do not | 68 | /* This is the very generalized SMBus access routine. You probably do not |
69 | want to use this, though; one of the functions below may be much easier, | 69 | want to use this, though; one of the functions below may be much easier, |
70 | and probably just as fast. | 70 | and probably just as fast. |
71 | Note that we use i2c_adapter here, because you do not need a specific | 71 | Note that we use i2c_adapter here, because you do not need a specific |
72 | smbus adapter to call this function. */ | 72 | smbus adapter to call this function. */ |
73 | extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, | 73 | extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, |
74 | unsigned short flags, | 74 | unsigned short flags, |
75 | char read_write, u8 command, int size, | 75 | char read_write, u8 command, int size, |
76 | union i2c_smbus_data * data); | 76 | union i2c_smbus_data * data); |
@@ -112,14 +112,14 @@ struct i2c_driver { | |||
112 | 112 | ||
113 | /* Notifies the driver that a new bus has appeared. This routine | 113 | /* Notifies the driver that a new bus has appeared. This routine |
114 | * can be used by the driver to test if the bus meets its conditions | 114 | * can be used by the driver to test if the bus meets its conditions |
115 | * & seek for the presence of the chip(s) it supports. If found, it | 115 | * & seek for the presence of the chip(s) it supports. If found, it |
116 | * registers the client(s) that are on the bus to the i2c admin. via | 116 | * registers the client(s) that are on the bus to the i2c admin. via |
117 | * i2c_attach_client. | 117 | * i2c_attach_client. |
118 | */ | 118 | */ |
119 | int (*attach_adapter)(struct i2c_adapter *); | 119 | int (*attach_adapter)(struct i2c_adapter *); |
120 | int (*detach_adapter)(struct i2c_adapter *); | 120 | int (*detach_adapter)(struct i2c_adapter *); |
121 | 121 | ||
122 | /* tells the driver that a client is about to be deleted & gives it | 122 | /* tells the driver that a client is about to be deleted & gives it |
123 | * the chance to remove its private data. Also, if the client struct | 123 | * the chance to remove its private data. Also, if the client struct |
124 | * has been dynamically allocated by the driver in the function above, | 124 | * has been dynamically allocated by the driver in the function above, |
125 | * it must be freed here. | 125 | * it must be freed here. |
@@ -139,13 +139,13 @@ struct i2c_driver { | |||
139 | #define I2C_NAME_SIZE 50 | 139 | #define I2C_NAME_SIZE 50 |
140 | 140 | ||
141 | /* | 141 | /* |
142 | * i2c_client identifies a single device (i.e. chip) that is connected to an | 142 | * i2c_client identifies a single device (i.e. chip) that is connected to an |
143 | * i2c bus. The behaviour is defined by the routines of the driver. This | 143 | * i2c bus. The behaviour is defined by the routines of the driver. This |
144 | * function is mainly used for lookup & other admin. functions. | 144 | * function is mainly used for lookup & other admin. functions. |
145 | */ | 145 | */ |
146 | struct i2c_client { | 146 | struct i2c_client { |
147 | unsigned int flags; /* div., see below */ | 147 | unsigned int flags; /* div., see below */ |
148 | unsigned short addr; /* chip address - NOTE: 7bit */ | 148 | unsigned short addr; /* chip address - NOTE: 7bit */ |
149 | /* addresses are stored in the */ | 149 | /* addresses are stored in the */ |
150 | /* _LOWER_ 7 bits */ | 150 | /* _LOWER_ 7 bits */ |
151 | struct i2c_adapter *adapter; /* the adapter we sit on */ | 151 | struct i2c_adapter *adapter; /* the adapter we sit on */ |
@@ -182,14 +182,14 @@ static inline void i2c_set_clientdata (struct i2c_client *dev, void *data) | |||
182 | */ | 182 | */ |
183 | struct i2c_algorithm { | 183 | struct i2c_algorithm { |
184 | /* If an adapter algorithm can't do I2C-level access, set master_xfer | 184 | /* If an adapter algorithm can't do I2C-level access, set master_xfer |
185 | to NULL. If an adapter algorithm can do SMBus access, set | 185 | to NULL. If an adapter algorithm can do SMBus access, set |
186 | smbus_xfer. If set to NULL, the SMBus protocol is simulated | 186 | smbus_xfer. If set to NULL, the SMBus protocol is simulated |
187 | using common I2C messages */ | 187 | using common I2C messages */ |
188 | /* master_xfer should return the number of messages successfully | 188 | /* master_xfer should return the number of messages successfully |
189 | processed, or a negative value on error */ | 189 | processed, or a negative value on error */ |
190 | int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs, | 190 | int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs, |
191 | int num); | 191 | int num); |
192 | int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, | 192 | int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, |
193 | unsigned short flags, char read_write, | 193 | unsigned short flags, char read_write, |
194 | u8 command, int size, union i2c_smbus_data * data); | 194 | u8 command, int size, union i2c_smbus_data * data); |
195 | 195 | ||
@@ -216,6 +216,7 @@ struct i2c_adapter { | |||
216 | int (*client_unregister)(struct i2c_client *); | 216 | int (*client_unregister)(struct i2c_client *); |
217 | 217 | ||
218 | /* data fields that are valid for all devices */ | 218 | /* data fields that are valid for all devices */ |
219 | u8 level; /* nesting level for lockdep */ | ||
219 | struct mutex bus_lock; | 220 | struct mutex bus_lock; |
220 | struct mutex clist_lock; | 221 | struct mutex clist_lock; |
221 | 222 | ||
@@ -316,7 +317,7 @@ extern int i2c_check_addr (struct i2c_adapter *adapter, int addr); | |||
316 | * It will only call found_proc if some client is connected at the | 317 | * It will only call found_proc if some client is connected at the |
317 | * specific address (unless a 'force' matched); | 318 | * specific address (unless a 'force' matched); |
318 | */ | 319 | */ |
319 | extern int i2c_probe(struct i2c_adapter *adapter, | 320 | extern int i2c_probe(struct i2c_adapter *adapter, |
320 | struct i2c_client_address_data *address_data, | 321 | struct i2c_client_address_data *address_data, |
321 | int (*found_proc) (struct i2c_adapter *, int, int)); | 322 | int (*found_proc) (struct i2c_adapter *, int, int)); |
322 | 323 | ||
@@ -352,15 +353,15 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap) | |||
352 | */ | 353 | */ |
353 | struct i2c_msg { | 354 | struct i2c_msg { |
354 | __u16 addr; /* slave address */ | 355 | __u16 addr; /* slave address */ |
355 | __u16 flags; | 356 | __u16 flags; |
356 | #define I2C_M_TEN 0x10 /* we have a ten bit chip address */ | 357 | #define I2C_M_TEN 0x10 /* we have a ten bit chip address */ |
357 | #define I2C_M_RD 0x01 | 358 | #define I2C_M_RD 0x01 |
358 | #define I2C_M_NOSTART 0x4000 | 359 | #define I2C_M_NOSTART 0x4000 |
359 | #define I2C_M_REV_DIR_ADDR 0x2000 | 360 | #define I2C_M_REV_DIR_ADDR 0x2000 |
360 | #define I2C_M_IGNORE_NAK 0x1000 | 361 | #define I2C_M_IGNORE_NAK 0x1000 |
361 | #define I2C_M_NO_RD_ACK 0x0800 | 362 | #define I2C_M_NO_RD_ACK 0x0800 |
362 | __u16 len; /* msg length */ | 363 | __u16 len; /* msg length */ |
363 | __u8 *buf; /* pointer to msg data */ | 364 | __u8 *buf; /* pointer to msg data */ |
364 | }; | 365 | }; |
365 | 366 | ||
366 | /* To determine what functionality is present */ | 367 | /* To determine what functionality is present */ |
@@ -370,16 +371,16 @@ struct i2c_msg { | |||
370 | #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ | 371 | #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ |
371 | #define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */ | 372 | #define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */ |
372 | #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ | 373 | #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ |
373 | #define I2C_FUNC_SMBUS_QUICK 0x00010000 | 374 | #define I2C_FUNC_SMBUS_QUICK 0x00010000 |
374 | #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 | 375 | #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 |
375 | #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 | 376 | #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 |
376 | #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 | 377 | #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 |
377 | #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 | 378 | #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 |
378 | #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 | 379 | #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 |
379 | #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 | 380 | #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 |
380 | #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 | 381 | #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 |
381 | #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 | 382 | #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 |
382 | #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 | 383 | #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 |
383 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ | 384 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ |
384 | #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ | 385 | #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ |
385 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */ | 386 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */ |
@@ -406,10 +407,10 @@ struct i2c_msg { | |||
406 | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ | 407 | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ |
407 | I2C_FUNC_SMBUS_I2C_BLOCK) | 408 | I2C_FUNC_SMBUS_I2C_BLOCK) |
408 | 409 | ||
409 | /* | 410 | /* |
410 | * Data for SMBus Messages | 411 | * Data for SMBus Messages |
411 | */ | 412 | */ |
412 | #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ | 413 | #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ |
413 | union i2c_smbus_data { | 414 | union i2c_smbus_data { |
414 | __u8 byte; | 415 | __u8 byte; |
415 | __u16 word; | 416 | __u16 word; |
@@ -421,11 +422,11 @@ union i2c_smbus_data { | |||
421 | #define I2C_SMBUS_READ 1 | 422 | #define I2C_SMBUS_READ 1 |
422 | #define I2C_SMBUS_WRITE 0 | 423 | #define I2C_SMBUS_WRITE 0 |
423 | 424 | ||
424 | /* SMBus transaction types (size parameter in the above functions) | 425 | /* SMBus transaction types (size parameter in the above functions) |
425 | Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ | 426 | Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ |
426 | #define I2C_SMBUS_QUICK 0 | 427 | #define I2C_SMBUS_QUICK 0 |
427 | #define I2C_SMBUS_BYTE 1 | 428 | #define I2C_SMBUS_BYTE 1 |
428 | #define I2C_SMBUS_BYTE_DATA 2 | 429 | #define I2C_SMBUS_BYTE_DATA 2 |
429 | #define I2C_SMBUS_WORD_DATA 3 | 430 | #define I2C_SMBUS_WORD_DATA 3 |
430 | #define I2C_SMBUS_PROC_CALL 4 | 431 | #define I2C_SMBUS_PROC_CALL 4 |
431 | #define I2C_SMBUS_BLOCK_DATA 5 | 432 | #define I2C_SMBUS_BLOCK_DATA 5 |
@@ -434,15 +435,15 @@ union i2c_smbus_data { | |||
434 | 435 | ||
435 | 436 | ||
436 | /* ----- commands for the ioctl like i2c_command call: | 437 | /* ----- commands for the ioctl like i2c_command call: |
437 | * note that additional calls are defined in the algorithm and hw | 438 | * note that additional calls are defined in the algorithm and hw |
438 | * dependent layers - these can be listed here, or see the | 439 | * dependent layers - these can be listed here, or see the |
439 | * corresponding header files. | 440 | * corresponding header files. |
440 | */ | 441 | */ |
441 | /* -> bit-adapter specific ioctls */ | 442 | /* -> bit-adapter specific ioctls */ |
442 | #define I2C_RETRIES 0x0701 /* number of times a device address */ | 443 | #define I2C_RETRIES 0x0701 /* number of times a device address */ |
443 | /* should be polled when not */ | 444 | /* should be polled when not */ |
444 | /* acknowledging */ | 445 | /* acknowledging */ |
445 | #define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ | 446 | #define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ |
446 | 447 | ||
447 | 448 | ||
448 | /* this is for i2c-dev.c */ | 449 | /* this is for i2c-dev.c */ |