Merge branch 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6

* 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6:
i2c: Fix OMAP clock prescaler to match the comment
i2c: Refactor a kfree in i2c-dev
i2c: Fix return value check in i2c-dev
i2c: Enable PEC on more i2c-i801 devices
i2c: Discard the i2c algo del_bus wrappers
i2c: New ARM Versatile/Realview bus driver
i2c: fix broken ds1337 initialization
i2c: i2c-i801 documentation update
i2c: Use the __ATTR macro where possible
i2c: Whitespace cleanups
i2c: Use put_user instead of copy_to_user where possible
i2c: New Atmel AT91 bus driver
i2c: Add support for nested i2c bus locking
i2c: Cleanups to the i2c-nforce2 bus driver
i2c: Add request/release_mem_region to i2c-ibm_iic bus driver
i2c: New Philips PNX bus driver
i2c: Delete the broken i2c-ite bus driver
i2c: Update the list of driver IDs
i2c: Fix documentation typos

+1730 -1590
-11
Documentation/feature-removal-schedule.txt
··· 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 219 What: Bridge netfilter deferred IPv4/IPv6 output hook calling 231 220 When: January 2007 232 221 Why: The deferred output hooks are a layering violation causing unusual
+1 -1
Documentation/i2c/busses/i2c-amd8111
··· 5 5 6 6 Datasheets: 7 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 9 follows. 10 10 11 11 Author: Vojtech Pavlik <vojtech@suse.cz>
+4 -1
Documentation/i2c/busses/i2c-i801
··· 9 9 * Intel 82801EB/ER (ICH5) (HW PEC supported, 32 byte buffer not supported) 10 10 * Intel 6300ESB 11 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 16 Datasheets: Publicly available at the Intel website 14 17 15 18 Authors:
+3 -3
Documentation/i2c/busses/i2c-nforce2
··· 10 10 * nForce4 MCP51 10de:0264 11 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 14 AMD-8111 SMBus 2.0 adapter. 15 15 16 16 Authors: 17 - Hans-Frieder Vogt <hfvogt@arcor.de>, 17 + Hans-Frieder Vogt <hfvogt@gmx.net>, 18 18 Thomas Leibold <thomas@plx.com>, 19 19 Patrick Dreker <patrick@dreker.de> 20 20 ··· 38 38 ----- 39 39 40 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 42 the driver to work with direct I/O access, which is different to the EC 43 43 interface of the AMD-8111. Tested on Asus A7N8X. The ACPI DSDT table of the 44 44 Asus A7N8X lists two SMBuses, both of which are supported by this driver.
+1 -1
arch/arm/mach-pnx4008/Makefile
··· 2 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 6 obj-m := 7 7 obj-n := 8 8 obj- :=
+167
arch/arm/mach-pnx4008/i2c.c
··· 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 + }
+13
arch/arm/mach-realview/core.c
··· 141 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 157 #define REALVIEW_SYSMCI (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_MCI_OFFSET) 145 158 146 159 static unsigned int realview_mmc_status(struct device *dev)
+1
arch/arm/mach-realview/core.h
··· 108 108 109 109 extern struct platform_device realview_flash_device; 110 110 extern struct platform_device realview_smc91x_device; 111 + extern struct platform_device realview_i2c_device; 111 112 extern struct mmc_platform_data realview_mmc0_plat_data; 112 113 extern struct mmc_platform_data realview_mmc1_plat_data; 113 114 extern struct clk realview_clcd_clk;
+1
arch/arm/mach-realview/realview_eb.c
··· 155 155 156 156 platform_device_register(&realview_flash_device); 157 157 platform_device_register(&realview_smc91x_device); 158 + platform_device_register(&realview_i2c_device); 158 159 159 160 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { 160 161 struct amba_device *d = amba_devs[i];
+14
arch/arm/mach-versatile/core.c
··· 325 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 341 #define VERSATILE_SYSMCI (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET) 329 342 330 343 unsigned int mmc_status(struct device *dev) ··· 788 775 clk_register(&versatile_clcd_clk); 789 776 790 777 platform_device_register(&versatile_flash_device); 778 + platform_device_register(&versatile_i2c_device); 791 779 platform_device_register(&smc91x_device); 792 780 793 781 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
+1 -1
drivers/acorn/char/i2c.c
··· 360 360 if (ret >= 0){ 361 361 ret = misc_register(&rtc_dev); 362 362 if(ret < 0) 363 - i2c_bit_del_bus(&ioc_ops); 363 + i2c_del_adapter(&ioc_ops); 364 364 } 365 365 366 366 return ret;
-11
drivers/i2c/algos/Kconfig
··· 38 38 This support is also available as a module. If so, the module 39 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 41 config I2C_ALGO8XX 53 42 tristate "MPC8xx CPM I2C interface" 54 43 depends on 8xx && I2C
-1
drivers/i2c/algos/Makefile
··· 5 5 obj-$(CONFIG_I2C_ALGOBIT) += i2c-algo-bit.o 6 6 obj-$(CONFIG_I2C_ALGOPCF) += i2c-algo-pcf.o 7 7 obj-$(CONFIG_I2C_ALGOPCA) += i2c-algo-pca.o 8 - obj-$(CONFIG_I2C_ALGOITE) += i2c-algo-ite.o 9 8 obj-$(CONFIG_I2C_ALGO_SGI) += i2c-algo-sgi.o 10 9 11 10 ifeq ($(CONFIG_I2C_DEBUG_ALGO),y)
-8
drivers/i2c/algos/i2c-algo-bit.c
··· 540 540 541 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 543 EXPORT_SYMBOL(i2c_bit_add_bus); 551 - EXPORT_SYMBOL(i2c_bit_del_bus); 552 544 553 545 MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 554 546 MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm");
-806
drivers/i2c/algos/i2c-algo-ite.c
··· 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);
-117
drivers/i2c/algos/i2c-algo-ite.h
··· 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 */
-7
drivers/i2c/algos/i2c-algo-pca.c
··· 381 381 382 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 384 EXPORT_SYMBOL(i2c_pca_add_bus); 391 - EXPORT_SYMBOL(i2c_pca_del_bus); 392 385 393 386 MODULE_AUTHOR("Ian Campbell <icampbell@arcom.com>"); 394 387 MODULE_DESCRIPTION("I2C-Bus PCA9564 algorithm");
-8
drivers/i2c/algos/i2c-algo-pcf.c
··· 486 486 487 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 489 EXPORT_SYMBOL(i2c_pcf_add_bus); 497 - EXPORT_SYMBOL(i2c_pcf_del_bus); 498 490 499 491 MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); 500 492 MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm");
-8
drivers/i2c/algos/i2c-algo-sgi.c
··· 171 171 172 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 174 EXPORT_SYMBOL(i2c_sgi_add_bus); 182 - EXPORT_SYMBOL(i2c_sgi_del_bus); 183 175 184 176 MODULE_AUTHOR("Ladislav Michl <ladis@linux-mips.org>"); 185 177 MODULE_DESCRIPTION("I2C-Bus SGI algorithm");
+37 -12
drivers/i2c/busses/Kconfig
··· 74 74 This driver can also be built as a module. If so, the module 75 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 84 config I2C_AU1550 78 85 tristate "Au1550/Au1200 SMBus interface" 79 86 depends on I2C && (SOC_AU1550 || SOC_AU1200) ··· 215 208 config I2C_ISA 216 209 tristate 217 210 depends on I2C 218 - 219 - config I2C_ITE 220 - tristate "ITE I2C Adapter" 221 - depends on I2C && MIPS_ITE8172 222 - select I2C_ALGOITE 223 - help 224 - This supports the ITE8172 I2C peripheral found on some MIPS 225 - systems. Say Y if you have one of these. You should also say Y for 226 - the ITE I2C driver algorithm support above. 227 - 228 - This support is also available as a module. If so, the module 229 - will be called i2c-ite. 230 211 231 212 config I2C_IXP4XX 232 213 tristate "IXP4xx GPIO-Based I2C Interface" ··· 476 481 477 482 If you don't know what to do here, definitely say N. 478 483 484 + config I2C_VERSATILE 485 + tristate "ARM Versatile/Realview I2C bus support" 486 + depends on I2C && (ARCH_VERSATILE || ARCH_REALVIEW) 487 + select I2C_ALGOBIT 488 + help 489 + Say yes if you want to support the I2C serial bus on ARMs Versatile 490 + range of platforms. 491 + 492 + This driver can also be built as a module. If so, the module 493 + will be called i2c-versatile. 494 + 479 495 config I2C_VIA 480 496 tristate "VIA 82C586B" 481 497 depends on I2C && PCI && EXPERIMENTAL ··· 553 547 554 548 This driver can also be built as a module. If so, the module 555 549 will be called i2c-mv64xxx. 550 + 551 + config I2C_PNX 552 + tristate "I2C bus support for Philips PNX targets" 553 + depends on ARCH_PNX4008 && I2C 554 + help 555 + This driver supports the Philips IP3204 I2C IP block master and/or 556 + slave controller 557 + 558 + This driver can also be built as a module. If so, the module 559 + will be called i2c-pnx. 560 + 561 + config I2C_PNX_EARLY 562 + bool "Early initialization for I2C on PNXxxxx" 563 + depends on I2C_PNX=y 564 + help 565 + Under certain circumstances one may need to make sure I2C on PNXxxxx 566 + is initialized earlier than some other driver that depends on it 567 + (for instance, that might be USB in case of PNX4008). With this 568 + option turned on you can guarantee that. 556 569 557 570 endmenu
+3 -1
drivers/i2c/busses/Makefile
··· 8 8 obj-$(CONFIG_I2C_AMD756) += i2c-amd756.o 9 9 obj-$(CONFIG_I2C_AMD756_S4882) += i2c-amd756-s4882.o 10 10 obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o 11 + obj-$(CONFIG_I2C_AT91) += i2c-at91.o 11 12 obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o 12 13 obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o 13 14 obj-$(CONFIG_I2C_HYDRA) += i2c-hydra.o ··· 17 16 obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o 18 17 obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o 19 18 obj-$(CONFIG_I2C_ISA) += i2c-isa.o 20 - obj-$(CONFIG_I2C_ITE) += i2c-ite.o 21 19 obj-$(CONFIG_I2C_IXP2000) += i2c-ixp2000.o 22 20 obj-$(CONFIG_I2C_IXP4XX) += i2c-ixp4xx.o 23 21 obj-$(CONFIG_I2C_POWERMAC) += i2c-powermac.o ··· 29 29 obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o 30 30 obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o 31 31 obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o 32 + obj-$(CONFIG_I2C_PNX) += i2c-pnx.o 32 33 obj-$(CONFIG_I2C_PROSAVAGE) += i2c-prosavage.o 33 34 obj-$(CONFIG_I2C_PXA) += i2c-pxa.o 34 35 obj-$(CONFIG_I2C_RPXLITE) += i2c-rpx.o ··· 40 39 obj-$(CONFIG_I2C_SIS630) += i2c-sis630.o 41 40 obj-$(CONFIG_I2C_SIS96X) += i2c-sis96x.o 42 41 obj-$(CONFIG_I2C_STUB) += i2c-stub.o 42 + obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o 43 43 obj-$(CONFIG_I2C_VIA) += i2c-via.o 44 44 obj-$(CONFIG_I2C_VIAPRO) += i2c-viapro.o 45 45 obj-$(CONFIG_I2C_VOODOO3) += i2c-voodoo3.o
+325
drivers/i2c/busses/i2c-at91.c
··· 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");
+1 -1
drivers/i2c/busses/i2c-elektor.c
··· 293 293 294 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 298 if (irq > 0) { 299 299 disable_irq(irq);
+1 -1
drivers/i2c/busses/i2c-hydra.c
··· 146 146 static void __devexit hydra_remove(struct pci_dev *dev) 147 147 { 148 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 150 iounmap(hydra_bit_data.data); 151 151 release_mem_region(pci_resource_start(dev, 0)+ 152 152 offsetof(struct Hydra, CachePD), 4);
+12 -4
drivers/i2c/busses/i2c-i801.c
··· 470 470 int err; 471 471 472 472 I801_dev = dev; 473 - if ((dev->device == PCI_DEVICE_ID_INTEL_82801DB_3) || 474 - (dev->device == PCI_DEVICE_ID_INTEL_82801EB_3) || 475 - (dev->device == PCI_DEVICE_ID_INTEL_ESB_4)) 473 + switch (dev->device) { 474 + case PCI_DEVICE_ID_INTEL_82801DB_3: 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 482 isich4 = 1; 477 - else 483 + break; 484 + default: 478 485 isich4 = 0; 486 + } 479 487 480 488 err = pci_enable_device(dev); 481 489 if (err) {
+3 -3
drivers/i2c/busses/i2c-i810.c
··· 219 219 return retval; 220 220 retval = i2c_bit_add_bus(&i810_ddc_adapter); 221 221 if (retval) 222 - i2c_bit_del_bus(&i810_i2c_adapter); 222 + i2c_del_adapter(&i810_i2c_adapter); 223 223 return retval; 224 224 } 225 225 226 226 static void __devexit i810_remove(struct pci_dev *dev) 227 227 { 228 - i2c_bit_del_bus(&i810_ddc_adapter); 229 - i2c_bit_del_bus(&i810_i2c_adapter); 228 + i2c_del_adapter(&i810_ddc_adapter); 229 + i2c_del_adapter(&i810_i2c_adapter); 230 230 iounmap(ioaddr); 231 231 } 232 232
+9
drivers/i2c/busses/i2c-ibm_iic.c
··· 680 680 dev->idx = ocp->def->index; 681 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 689 if (!(dev->vaddr = ioremap(ocp->def->paddr, sizeof(struct iic_regs)))){ 684 690 printk(KERN_CRIT "ibm-iic%d: failed to ioremap device registers\n", 685 691 dev->idx); ··· 756 750 757 751 iounmap(dev->vaddr); 758 752 fail2: 753 + release_mem_region(ocp->def->paddr, sizeof(struct iic_regs)); 754 + fail1: 759 755 ocp_set_drvdata(ocp, NULL); 760 756 kfree(dev); 761 757 return ret; ··· 785 777 free_irq(dev->irq, dev); 786 778 } 787 779 iounmap(dev->vaddr); 780 + release_mem_region(ocp->def->paddr, sizeof(struct iic_regs)); 788 781 kfree(dev); 789 782 } 790 783 }
-278
drivers/i2c/busses/i2c-ite.c
··· 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);
+1 -1
drivers/i2c/busses/i2c-ixp2000.c
··· 90 90 91 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 95 kfree(drv_data); 96 96
+1 -1
drivers/i2c/busses/i2c-ixp4xx.c
··· 91 91 92 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 96 kfree(drv_data); 97 97
+14 -75
drivers/i2c/busses/i2c-nforce2.c
··· 35 35 nForce4 MCP55 0368 36 36 37 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 41 /* Note: we assume there can only be one nForce2, with two SMBus interfaces */ ··· 52 52 #include <asm/io.h> 53 53 54 54 MODULE_LICENSE("GPL"); 55 - MODULE_AUTHOR ("Hans-Frieder Vogt <hfvogt@arcor.de>"); 56 - MODULE_DESCRIPTION("nForce2 SMBus driver"); 55 + MODULE_AUTHOR ("Hans-Frieder Vogt <hfvogt@gmx.net>"); 56 + MODULE_DESCRIPTION("nForce2/3/4/5xx SMBus driver"); 57 57 58 58 59 59 struct nforce2_smbus { ··· 80 80 #define NVIDIA_SMB_ADDR (smbus->base + 0x02) /* address */ 81 81 #define NVIDIA_SMB_CMD (smbus->base + 0x03) /* command */ 82 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 84 #define NVIDIA_SMB_STS_DONE 0x80 88 85 #define NVIDIA_SMB_STS_ALRM 0x40 ··· 92 95 #define NVIDIA_SMB_PRTCL_BYTE 0x04 93 96 #define NVIDIA_SMB_PRTCL_BYTE_DATA 0x06 94 97 #define NVIDIA_SMB_PRTCL_WORD_DATA 0x08 95 - #define NVIDIA_SMB_PRTCL_BLOCK_DATA 0x0a 96 - #define NVIDIA_SMB_PRTCL_PROC_CALL 0x0c 97 - #define NVIDIA_SMB_PRTCL_BLOCK_PROC_CALL 0x0d 98 - #define NVIDIA_SMB_PRTCL_I2C_BLOCK_DATA 0x4a 99 98 #define NVIDIA_SMB_PRTCL_PEC 0x80 100 99 101 100 static struct pci_driver nforce2_driver; 102 101 103 - static s32 nforce2_access(struct i2c_adapter *adap, u16 addr, 104 - unsigned short flags, char read_write, 105 - u8 command, int size, union i2c_smbus_data *data); 106 - static u32 nforce2_func(struct i2c_adapter *adapter); 107 - 108 - 109 - static const struct i2c_algorithm smbus_algorithm = { 110 - .smbus_xfer = nforce2_access, 111 - .functionality = nforce2_func, 112 - }; 113 - 114 - static struct i2c_adapter nforce2_adapter = { 115 - .owner = THIS_MODULE, 116 - .class = I2C_CLASS_HWMON, 117 - .algo = &smbus_algorithm, 118 - }; 119 - 120 - /* Return -1 on error. See smbus.h for more information */ 102 + /* Return -1 on error */ 121 103 static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, 122 104 unsigned short flags, char read_write, 123 105 u8 command, int size, union i2c_smbus_data * data) 124 106 { 125 107 struct nforce2_smbus *smbus = adap->algo_data; 126 108 unsigned char protocol, pec, temp; 127 - unsigned char len = 0; /* to keep the compiler quiet */ 128 - int i; 129 109 130 110 protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ : 131 111 NVIDIA_SMB_PRTCL_WRITE; ··· 136 162 } 137 163 protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec; 138 164 break; 139 - 140 - case I2C_SMBUS_BLOCK_DATA: 141 - outb_p(command, NVIDIA_SMB_CMD); 142 - if (read_write == I2C_SMBUS_WRITE) { 143 - len = min_t(u8, data->block[0], 32); 144 - outb_p(len, NVIDIA_SMB_BCNT); 145 - for (i = 0; i < len; i++) 146 - outb_p(data->block[i + 1], NVIDIA_SMB_DATA+i); 147 - } 148 - protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec; 149 - break; 150 - 151 - case I2C_SMBUS_I2C_BLOCK_DATA: 152 - len = min_t(u8, data->block[0], 32); 153 - outb_p(command, NVIDIA_SMB_CMD); 154 - outb_p(len, NVIDIA_SMB_BCNT); 155 - if (read_write == I2C_SMBUS_WRITE) 156 - for (i = 0; i < len; i++) 157 - outb_p(data->block[i + 1], NVIDIA_SMB_DATA+i); 158 - protocol |= NVIDIA_SMB_PRTCL_I2C_BLOCK_DATA; 159 - break; 160 - 161 - case I2C_SMBUS_PROC_CALL: 162 - dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n"); 163 - return -1; 164 - 165 - case I2C_SMBUS_BLOCK_PROC_CALL: 166 - dev_err(&adap->dev, "I2C_SMBUS_BLOCK_PROC_CALL not supported!\n"); 167 - return -1; 168 165 169 166 default: 170 167 dev_err(&adap->dev, "Unsupported transaction %d\n", size); ··· 172 227 break; 173 228 174 229 case I2C_SMBUS_WORD_DATA: 175 - /* case I2C_SMBUS_PROC_CALL: not supported */ 176 230 data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA+1) << 8); 177 - break; 178 - 179 - case I2C_SMBUS_BLOCK_DATA: 180 - /* case I2C_SMBUS_BLOCK_PROC_CALL: not supported */ 181 - len = inb_p(NVIDIA_SMB_BCNT); 182 - len = min_t(u8, len, 32); 183 - case I2C_SMBUS_I2C_BLOCK_DATA: 184 - for (i = 0; i < len; i++) 185 - data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i); 186 - data->block[0] = len; 187 231 break; 188 232 } 189 233 ··· 184 250 { 185 251 /* other functionality might be possible, but is not tested */ 186 252 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | 187 - I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA /* | 188 - I2C_FUNC_SMBUS_BLOCK_DATA */; 253 + I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA; 189 254 } 255 + 256 + static struct i2c_algorithm smbus_algorithm = { 257 + .smbus_xfer = nforce2_access, 258 + .functionality = nforce2_func, 259 + }; 190 260 191 261 192 262 static struct pci_device_id nforce2_ids[] = { ··· 204 266 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS) }, 205 267 { 0 } 206 268 }; 207 - 208 269 209 270 MODULE_DEVICE_TABLE (pci, nforce2_ids); 210 271 ··· 228 291 } 229 292 230 293 smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK; 231 - smbus->size = 8; 294 + smbus->size = 64; 232 295 } 233 296 smbus->dev = dev; 234 297 ··· 237 300 smbus->base, smbus->base+smbus->size-1, name); 238 301 return -1; 239 302 } 240 - smbus->adapter = nforce2_adapter; 303 + smbus->adapter.owner = THIS_MODULE; 304 + smbus->adapter.class = I2C_CLASS_HWMON; 305 + smbus->adapter.algo = &smbus_algorithm; 241 306 smbus->adapter.algo_data = smbus; 242 307 smbus->adapter.dev.parent = &dev->dev; 243 308 snprintf(smbus->adapter.name, I2C_NAME_SIZE,
+2 -2
drivers/i2c/busses/i2c-omap.c
··· 231 231 * 13 2 1 232 232 * 19.2 2 1 233 233 */ 234 - if (fclk_rate > 16000000) 235 - psc = (fclk_rate + 8000000) / 12000000; 234 + if (fclk_rate > 12000000) 235 + psc = fclk_rate / 12000000; 236 236 } 237 237 238 238 /* Setup clock prescaler to obtain approx 12MHz I2C module clock: */
+1 -1
drivers/i2c/busses/i2c-parport-light.c
··· 163 163 if (adapter_parm[type].init.val) 164 164 line_set(0, &adapter_parm[type].init); 165 165 166 - i2c_bit_del_bus(&parport_adapter); 166 + i2c_del_adapter(&parport_adapter); 167 167 release_region(base, 3); 168 168 } 169 169
+1 -1
drivers/i2c/busses/i2c-parport.c
··· 218 218 if (adapter_parm[type].init.val) 219 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 222 parport_unregister_device(adapter->pdev); 223 223 if (prev) 224 224 prev->next = adapter->next;
+1 -1
drivers/i2c/busses/i2c-pca-isa.c
··· 156 156 157 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 161 if (irq > 0) { 162 162 disable_irq(irq);
+708
drivers/i2c/busses/i2c-pnx.c
··· 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);
+1 -1
drivers/i2c/busses/i2c-prosavage.c
··· 212 212 if (chip->i2c_bus[i].adap_ok == 0) 213 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 216 if (ret) { 217 217 dev_err(&dev->dev, "%s not removed\n", 218 218 chip->i2c_bus[i].adap.name);
+1 -1
drivers/i2c/busses/i2c-savage4.c
··· 173 173 174 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 177 iounmap(ioaddr); 178 178 } 179 179
+153
drivers/i2c/busses/i2c-versatile.c
··· 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");
+1 -1
drivers/i2c/busses/i2c-via.c
··· 151 151 152 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 155 release_region(I2C_DIR, IOSPACE); 156 156 pm_io_base = 0; 157 157 }
+3 -3
drivers/i2c/busses/i2c-voodoo3.c
··· 211 211 return retval; 212 212 retval = i2c_bit_add_bus(&voodoo3_ddc_adapter); 213 213 if (retval) 214 - i2c_bit_del_bus(&voodoo3_i2c_adapter); 214 + i2c_del_adapter(&voodoo3_i2c_adapter); 215 215 return retval; 216 216 } 217 217 218 218 static void __devexit voodoo3_remove(struct pci_dev *dev) 219 219 { 220 - i2c_bit_del_bus(&voodoo3_i2c_adapter); 221 - i2c_bit_del_bus(&voodoo3_ddc_adapter); 220 + i2c_del_adapter(&voodoo3_i2c_adapter); 221 + i2c_del_adapter(&voodoo3_ddc_adapter); 222 222 iounmap(ioaddr); 223 223 } 224 224
+1 -1
drivers/i2c/busses/scx200_i2c.c
··· 116 116 117 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 122 module_init(scx200_i2c_init);
+7 -1
drivers/i2c/chips/ds1337.c
··· 347 347 348 348 if ((status & 0x80) || (control & 0x80)) { 349 349 /* RTC not running */ 350 - u8 buf[16]; 350 + u8 buf[1+16]; /* First byte is interpreted as address */ 351 351 struct i2c_msg msg[1]; 352 352 353 353 dev_dbg(&client->dev, "%s: RTC not running!\n", __FUNCTION__); 354 354 355 355 /* Initialize all, including STATUS and CONTROL to zero */ 356 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 363 msg[0].addr = client->addr; 358 364 msg[0].flags = 0; 359 365 msg[0].len = sizeof(buf);
+32 -35
drivers/i2c/i2c-core.c
··· 127 127 return sprintf(buf, "%s\n", client->name); 128 128 } 129 129 130 - /* 131 - * We can't use the DEVICE_ATTR() macro here as we want the same filename for a 132 - * different type of a device. So beware if the DEVICE_ATTR() macro ever 133 - * changes, this definition will also have to change. 130 + /* 131 + * We can't use the DEVICE_ATTR() macro here, as we used the same name for 132 + * an i2c adapter attribute (above). 134 133 */ 135 - static struct device_attribute dev_attr_client_name = { 136 - .attr = {.name = "name", .mode = S_IRUGO, .owner = THIS_MODULE }, 137 - .show = &show_client_name, 138 - }; 134 + static struct device_attribute dev_attr_client_name = 135 + __ATTR(name, S_IRUGO, &show_client_name, NULL); 139 136 140 137 141 138 /* --------------------------------------------------- 142 - * registering functions 143 - * --------------------------------------------------- 139 + * registering functions 140 + * --------------------------------------------------- 144 141 */ 145 142 146 143 /* ----- ··· 311 314 res = driver_register(&driver->driver); 312 315 if (res) 313 316 return res; 314 - 317 + 315 318 mutex_lock(&core_lists); 316 319 317 320 list_add_tail(&driver->list,&drivers); ··· 335 338 struct list_head *item1, *item2, *_n; 336 339 struct i2c_client *client; 337 340 struct i2c_adapter *adap; 338 - 341 + 339 342 int res = 0; 340 343 341 344 mutex_lock(&core_lists); 342 345 343 346 /* Have a look at each adapter, if clients of this driver are still 344 - * attached. If so, detach them to be able to kill the driver 347 + * attached. If so, detach them to be able to kill the driver 345 348 * afterwards. 346 349 */ 347 350 list_for_each(item1,&adapters) { ··· 416 419 goto out_unlock; 417 420 } 418 421 list_add_tail(&client->list,&adapter->clients); 419 - 422 + 420 423 client->usage_count = 0; 421 424 422 425 client->dev.parent = &client->adapter->dev; 423 426 client->dev.driver = &client->driver->driver; 424 427 client->dev.bus = &i2c_bus_type; 425 428 client->dev.release = &i2c_client_release; 426 - 429 + 427 430 snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), 428 431 "%d-%04x", i2c_adapter_id(adapter), client->addr); 429 432 dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n", ··· 464 467 { 465 468 struct i2c_adapter *adapter = client->adapter; 466 469 int res = 0; 467 - 470 + 468 471 if (client->usage_count > 0) { 469 472 dev_warn(&client->dev, "Client [%s] still busy, " 470 473 "can't detach\n", client->name); ··· 532 535 __FUNCTION__); 533 536 return -EPERM; 534 537 } 535 - 538 + 536 539 client->usage_count--; 537 540 i2c_dec_use_client(client); 538 - 541 + 539 542 return 0; 540 543 } 541 544 ··· 600 603 } 601 604 #endif 602 605 603 - mutex_lock(&adap->bus_lock); 606 + mutex_lock_nested(&adap->bus_lock, adap->level); 604 607 ret = adap->algo->master_xfer(adap,msgs,num); 605 608 mutex_unlock(&adap->bus_lock); 606 609 ··· 621 624 msg.flags = client->flags & I2C_M_TEN; 622 625 msg.len = count; 623 626 msg.buf = (char *)buf; 624 - 627 + 625 628 ret = i2c_transfer(adap, &msg, 1); 626 629 627 630 /* If everything went ok (i.e. 1 msg transmitted), return #bytes ··· 754 757 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { 755 758 if (address_data->probe[0] == I2C_CLIENT_END 756 759 && address_data->normal_i2c[0] == I2C_CLIENT_END) 757 - return 0; 760 + return 0; 758 761 759 762 dev_warn(&adapter->dev, "SMBus Quick command not supported, " 760 763 "can't probe for chips\n"); ··· 814 817 struct i2c_adapter* i2c_get_adapter(int id) 815 818 { 816 819 struct i2c_adapter *adapter; 817 - 820 + 818 821 mutex_lock(&core_lists); 819 822 adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); 820 823 if (adapter && !try_module_get(adapter->owner)) ··· 831 834 832 835 /* The SMBus parts */ 833 836 834 - #define POLY (0x1070U << 3) 837 + #define POLY (0x1070U << 3) 835 838 static u8 836 839 crc8(u16 data) 837 840 { 838 841 int i; 839 - 842 + 840 843 for(i = 0; i < 8; i++) { 841 - if (data & 0x8000) 844 + if (data & 0x8000) 842 845 data = data ^ POLY; 843 846 data = data << 1; 844 847 } ··· 888 891 rpec, cpec); 889 892 return -1; 890 893 } 891 - return 0; 894 + return 0; 892 895 } 893 896 894 897 s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value) 895 898 { 896 899 return i2c_smbus_xfer(client->adapter,client->addr,client->flags, 897 - value,0,I2C_SMBUS_QUICK,NULL); 900 + value,0,I2C_SMBUS_QUICK,NULL); 898 901 } 899 902 900 903 s32 i2c_smbus_read_byte(struct i2c_client *client) ··· 993 996 I2C_SMBUS_I2C_BLOCK_DATA, &data); 994 997 } 995 998 996 - /* Simulate a SMBus command using the i2c protocol 999 + /* Simulate a SMBus command using the i2c protocol 997 1000 No checking of parameters is done! */ 998 - static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, 1001 + static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, 999 1002 unsigned short flags, 1000 - char read_write, u8 command, int size, 1003 + char read_write, u8 command, int size, 1001 1004 union i2c_smbus_data * data) 1002 1005 { 1003 1006 /* So we need to generate a series of msgs. In the case of writing, we ··· 1007 1010 unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; 1008 1011 unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; 1009 1012 int num = read_write == I2C_SMBUS_READ?2:1; 1010 - struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, 1013 + struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, 1011 1014 { addr, flags | I2C_M_RD, 0, msgbuf1 } 1012 1015 }; 1013 1016 int i; ··· 1100 1103 if (i) { 1101 1104 /* Compute PEC if first message is a write */ 1102 1105 if (!(msg[0].flags & I2C_M_RD)) { 1103 - if (num == 1) /* Write only */ 1106 + if (num == 1) /* Write only */ 1104 1107 i2c_smbus_add_pec(&msg[0]); 1105 1108 else /* Write followed by read */ 1106 1109 partial_pec = i2c_smbus_msg_pec(0, &msg[0]); 1107 1110 } 1108 1111 /* Ask for PEC if last message is a read */ 1109 1112 if (msg[num-1].flags & I2C_M_RD) 1110 - msg[num-1].len++; 1113 + msg[num-1].len++; 1111 1114 } 1112 1115 1113 1116 if (i2c_transfer(adapter, msg, num) < 0) ··· 1127 1130 case I2C_SMBUS_BYTE_DATA: 1128 1131 data->byte = msgbuf1[0]; 1129 1132 break; 1130 - case I2C_SMBUS_WORD_DATA: 1133 + case I2C_SMBUS_WORD_DATA: 1131 1134 case I2C_SMBUS_PROC_CALL: 1132 1135 data->word = msgbuf1[0] | (msgbuf1[1] << 8); 1133 1136 break; ··· 1143 1146 1144 1147 1145 1148 s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, 1146 - char read_write, u8 command, int size, 1149 + char read_write, u8 command, int size, 1147 1150 union i2c_smbus_data * data) 1148 1151 { 1149 1152 s32 res;
+21 -23
drivers/i2c/i2c-dev.c
··· 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 4 Copyright (C) 1995-97 Simon G. Vogl 5 5 Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl> ··· 90 90 spin_lock(&i2c_dev_list_lock); 91 91 list_del(&i2c_dev->list); 92 92 spin_unlock(&i2c_dev_list_lock); 93 + kfree(i2c_dev); 93 94 } 94 95 95 96 static ssize_t show_adapter_name(struct device *dev, ··· 173 172 switch ( cmd ) { 174 173 case I2C_SLAVE: 175 174 case I2C_SLAVE_FORCE: 176 - if ((arg > 0x3ff) || 175 + if ((arg > 0x3ff) || 177 176 (((client->flags & I2C_M_TEN) == 0) && arg > 0x7f)) 178 177 return -EINVAL; 179 178 if ((cmd == I2C_SLAVE) && i2c_check_addr(client->adapter,arg)) ··· 194 193 return 0; 195 194 case I2C_FUNCS: 196 195 funcs = i2c_get_functionality(client->adapter); 197 - return (copy_to_user((unsigned long __user *)arg, &funcs, 198 - sizeof(unsigned long)))?-EFAULT:0; 196 + return put_user(funcs, (unsigned long __user *)arg); 199 197 200 198 case I2C_RDWR: 201 - if (copy_from_user(&rdwr_arg, 202 - (struct i2c_rdwr_ioctl_data __user *)arg, 199 + if (copy_from_user(&rdwr_arg, 200 + (struct i2c_rdwr_ioctl_data __user *)arg, 203 201 sizeof(rdwr_arg))) 204 202 return -EFAULT; 205 203 ··· 206 206 * be sent at once */ 207 207 if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) 208 208 return -EINVAL; 209 - 209 + 210 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 212 GFP_KERNEL); 213 213 214 214 if (rdwr_pa == NULL) return -ENOMEM; ··· 278 278 (struct i2c_smbus_ioctl_data __user *) arg, 279 279 sizeof(struct i2c_smbus_ioctl_data))) 280 280 return -EFAULT; 281 - if ((data_arg.size != I2C_SMBUS_BYTE) && 281 + if ((data_arg.size != I2C_SMBUS_BYTE) && 282 282 (data_arg.size != I2C_SMBUS_QUICK) && 283 - (data_arg.size != I2C_SMBUS_BYTE_DATA) && 283 + (data_arg.size != I2C_SMBUS_BYTE_DATA) && 284 284 (data_arg.size != I2C_SMBUS_WORD_DATA) && 285 285 (data_arg.size != I2C_SMBUS_PROC_CALL) && 286 286 (data_arg.size != I2C_SMBUS_BLOCK_DATA) && ··· 291 291 data_arg.size); 292 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 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 297 (data_arg.read_write != I2C_SMBUS_WRITE)) { 298 - dev_dbg(&client->adapter->dev, 298 + dev_dbg(&client->adapter->dev, 299 299 "read_write out of range (%x) in ioctl I2C_SMBUS.\n", 300 300 data_arg.read_write); 301 301 return -EINVAL; ··· 304 304 /* Note that command values are always valid! */ 305 305 306 306 if ((data_arg.size == I2C_SMBUS_QUICK) || 307 - ((data_arg.size == I2C_SMBUS_BYTE) && 307 + ((data_arg.size == I2C_SMBUS_BYTE) && 308 308 (data_arg.read_write == I2C_SMBUS_WRITE))) 309 309 /* These are special: we do not use data */ 310 310 return i2c_smbus_xfer(client->adapter, client->addr, ··· 322 322 if ((data_arg.size == I2C_SMBUS_BYTE_DATA) || 323 323 (data_arg.size == I2C_SMBUS_BYTE)) 324 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 326 (data_arg.size == I2C_SMBUS_PROC_CALL)) 327 327 datasize = sizeof(data_arg.data->word); 328 328 else /* size == smbus block, i2c block, or block proc. call */ 329 329 datasize = sizeof(data_arg.data->block); 330 330 331 - if ((data_arg.size == I2C_SMBUS_PROC_CALL) || 332 - (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || 331 + if ((data_arg.size == I2C_SMBUS_PROC_CALL) || 332 + (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || 333 333 (data_arg.read_write == I2C_SMBUS_WRITE)) { 334 334 if (copy_from_user(&temp, data_arg.data, datasize)) 335 335 return -EFAULT; ··· 337 337 res = i2c_smbus_xfer(client->adapter,client->addr,client->flags, 338 338 data_arg.read_write, 339 339 data_arg.command,data_arg.size,&temp); 340 - if (! res && ((data_arg.size == I2C_SMBUS_PROC_CALL) || 341 - (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || 340 + if (! res && ((data_arg.size == I2C_SMBUS_PROC_CALL) || 341 + (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || 342 342 (data_arg.read_write == I2C_SMBUS_READ))) { 343 343 if (copy_to_user(data_arg.data, &temp, datasize)) 344 344 return -EFAULT; ··· 417 417 i2c_dev->dev = device_create(i2c_dev_class, &adap->dev, 418 418 MKDEV(I2C_MAJOR, adap->nr), 419 419 "i2c-%d", adap->nr); 420 - if (!i2c_dev->dev) { 421 - res = -ENODEV; 420 + if (IS_ERR(i2c_dev->dev)) { 421 + res = PTR_ERR(i2c_dev->dev); 422 422 goto error; 423 423 } 424 424 res = device_create_file(i2c_dev->dev, &dev_attr_name); ··· 432 432 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); 433 433 error: 434 434 return_i2c_dev(i2c_dev); 435 - kfree(i2c_dev); 436 435 return res; 437 436 } 438 437 ··· 446 447 device_remove_file(i2c_dev->dev, &dev_attr_name); 447 448 return_i2c_dev(i2c_dev); 448 449 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); 449 - kfree(i2c_dev); 450 450 451 451 pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); 452 452 return 0;
+1 -1
drivers/ieee1394/pcilynx.c
··· 1485 1485 1486 1486 } 1487 1487 1488 - i2c_bit_del_bus(i2c_ad); 1488 + i2c_del_adapter(i2c_ad); 1489 1489 kfree(i2c_ad); 1490 1490 } 1491 1491 }
+4 -4
drivers/media/dvb/pluto2/pluto2.c
··· 650 650 /* dvb */ 651 651 ret = dvb_register_adapter(&pluto->dvb_adapter, DRIVER_NAME, THIS_MODULE, &pdev->dev); 652 652 if (ret < 0) 653 - goto err_i2c_bit_del_bus; 653 + goto err_i2c_del_adapter; 654 654 655 655 dvb_adapter = &pluto->dvb_adapter; 656 656 ··· 712 712 dvb_dmx_release(dvbdemux); 713 713 err_dvb_unregister_adapter: 714 714 dvb_unregister_adapter(dvb_adapter); 715 - err_i2c_bit_del_bus: 716 - i2c_bit_del_bus(&pluto->i2c_adap); 715 + err_i2c_del_adapter: 716 + i2c_del_adapter(&pluto->i2c_adap); 717 717 err_pluto_hw_exit: 718 718 pluto_hw_exit(pluto); 719 719 err_free_irq: ··· 748 748 dvb_dmxdev_release(&pluto->dmxdev); 749 749 dvb_dmx_release(dvbdemux); 750 750 dvb_unregister_adapter(dvb_adapter); 751 - i2c_bit_del_bus(&pluto->i2c_adap); 751 + i2c_del_adapter(&pluto->i2c_adap); 752 752 pluto_hw_exit(pluto); 753 753 free_irq(pdev->irq, pluto); 754 754 pci_iounmap(pdev, pluto->io_mem);
+1 -5
drivers/media/video/bt8xx/bttv-i2c.c
··· 479 479 if (0 != btv->i2c_rc) 480 480 return 0; 481 481 482 - if (btv->use_i2c_hw) { 483 - return i2c_del_adapter(&btv->c.i2c_adap); 484 - } else { 485 - return i2c_bit_del_bus(&btv->c.i2c_adap); 486 - } 482 + return i2c_del_adapter(&btv->c.i2c_adap); 487 483 } 488 484 489 485 /*
+1 -1
drivers/media/video/cx88/cx88-core.c
··· 1153 1153 mutex_lock(&devlist); 1154 1154 cx88_ir_fini(core); 1155 1155 if (0 == core->i2c_rc) 1156 - i2c_bit_del_bus(&core->i2c_adap); 1156 + i2c_del_adapter(&core->i2c_adap); 1157 1157 list_del(&core->devlist); 1158 1158 iounmap(core->lmmio); 1159 1159 cx88_devcount--;
+1 -1
drivers/media/video/cx88/cx88-vp3054-i2c.c
··· 168 168 dev->core->board != CX88_BOARD_DNTV_LIVE_DVB_T_PRO) 169 169 return; 170 170 171 - i2c_bit_del_bus(&vp3054_i2c->adap); 171 + i2c_del_adapter(&vp3054_i2c->adap); 172 172 kfree(vp3054_i2c); 173 173 } 174 174
+1 -1
drivers/media/video/vino.c
··· 782 782 783 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 788 static int i2c_camera_command(unsigned int cmd, void *arg)
+1 -1
drivers/media/video/zoran_card.c
··· 849 849 static void 850 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 855 /* Check a zoran_params struct for correctness, insert default params */
+4 -4
drivers/video/aty/radeon_i2c.c
··· 120 120 void radeon_delete_i2c_busses(struct radeonfb_info *rinfo) 121 121 { 122 122 if (rinfo->i2c[0].rinfo) 123 - i2c_bit_del_bus(&rinfo->i2c[0].adapter); 123 + i2c_del_adapter(&rinfo->i2c[0].adapter); 124 124 rinfo->i2c[0].rinfo = NULL; 125 125 126 126 if (rinfo->i2c[1].rinfo) 127 - i2c_bit_del_bus(&rinfo->i2c[1].adapter); 127 + i2c_del_adapter(&rinfo->i2c[1].adapter); 128 128 rinfo->i2c[1].rinfo = NULL; 129 129 130 130 if (rinfo->i2c[2].rinfo) 131 - i2c_bit_del_bus(&rinfo->i2c[2].adapter); 131 + i2c_del_adapter(&rinfo->i2c[2].adapter); 132 132 rinfo->i2c[2].rinfo = NULL; 133 133 134 134 if (rinfo->i2c[3].rinfo) 135 - i2c_bit_del_bus(&rinfo->i2c[3].adapter); 135 + i2c_del_adapter(&rinfo->i2c[3].adapter); 136 136 rinfo->i2c[3].rinfo = NULL; 137 137 } 138 138
+3 -3
drivers/video/i810/i810-i2c.c
··· 137 137 void i810_delete_i2c_busses(struct i810fb_par *par) 138 138 { 139 139 if (par->chan[0].par) 140 - i2c_bit_del_bus(&par->chan[0].adapter); 140 + i2c_del_adapter(&par->chan[0].adapter); 141 141 par->chan[0].par = NULL; 142 142 143 143 if (par->chan[1].par) 144 - i2c_bit_del_bus(&par->chan[1].adapter); 144 + i2c_del_adapter(&par->chan[1].adapter); 145 145 par->chan[1].par = NULL; 146 146 147 147 if (par->chan[2].par) 148 - i2c_bit_del_bus(&par->chan[2].adapter); 148 + i2c_del_adapter(&par->chan[2].adapter); 149 149 par->chan[2].par = NULL; 150 150 } 151 151
+2 -2
drivers/video/intelfb/intelfb_i2c.c
··· 188 188 189 189 for (i = 0; i < MAX_OUTPUTS; i++) { 190 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 192 dinfo->output[i].i2c_bus.dinfo = NULL; 193 193 } 194 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 196 dinfo->output[i].ddc_bus.dinfo = NULL; 197 197 } 198 198 }
+1 -1
drivers/video/matrox/i2c-matroxfb.c
··· 124 124 125 125 static void i2c_bit_bus_del(struct i2c_bit_adapter* b) { 126 126 if (b->initialized) { 127 - i2c_bit_del_bus(&b->adapter); 127 + i2c_del_adapter(&b->adapter); 128 128 b->initialized = 0; 129 129 } 130 130 }
+3 -3
drivers/video/nvidia/nv_i2c.c
··· 147 147 void nvidia_delete_i2c_busses(struct nvidia_par *par) 148 148 { 149 149 if (par->chan[0].par) 150 - i2c_bit_del_bus(&par->chan[0].adapter); 150 + i2c_del_adapter(&par->chan[0].adapter); 151 151 par->chan[0].par = NULL; 152 152 153 153 if (par->chan[1].par) 154 - i2c_bit_del_bus(&par->chan[1].adapter); 154 + i2c_del_adapter(&par->chan[1].adapter); 155 155 par->chan[1].par = NULL; 156 156 157 157 if (par->chan[2].par) 158 - i2c_bit_del_bus(&par->chan[2].adapter); 158 + i2c_del_adapter(&par->chan[2].adapter); 159 159 par->chan[2].par = NULL; 160 160 161 161 }
+3 -3
drivers/video/riva/rivafb-i2c.c
··· 144 144 void riva_delete_i2c_busses(struct riva_par *par) 145 145 { 146 146 if (par->chan[0].par) 147 - i2c_bit_del_bus(&par->chan[0].adapter); 147 + i2c_del_adapter(&par->chan[0].adapter); 148 148 par->chan[0].par = NULL; 149 149 150 150 if (par->chan[1].par) 151 - i2c_bit_del_bus(&par->chan[1].adapter); 151 + i2c_del_adapter(&par->chan[1].adapter); 152 152 par->chan[1].par = NULL; 153 153 154 154 if (par->chan[2].par) 155 - i2c_bit_del_bus(&par->chan[2].adapter); 155 + i2c_del_adapter(&par->chan[2].adapter); 156 156 par->chan[2].par = NULL; 157 157 } 158 158
+1 -1
drivers/video/savage/savagefb-i2c.c
··· 208 208 struct savagefb_par *par = info->par; 209 209 210 210 if (par->chan.par) 211 - i2c_bit_del_bus(&par->chan.adapter); 211 + i2c_del_adapter(&par->chan.adapter); 212 212 213 213 par->chan.par = NULL; 214 214 }
+67
include/asm-arm/arch-pnx4008/i2c.h
··· 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___ */
+2 -3
include/linux/i2c-algo-bit.h
··· 26 26 27 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 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 33 struct i2c_algo_bit_data { 34 34 void *data; /* private data for lowlevel routines */ ··· 44 44 }; 45 45 46 46 int i2c_bit_add_bus(struct i2c_adapter *); 47 - int i2c_bit_del_bus(struct i2c_adapter *); 48 47 49 48 #endif /* _LINUX_I2C_ALGO_BIT_H */
-72
include/linux/i2c-algo-ite.h
··· 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 */
-1
include/linux/i2c-algo-pca.h
··· 10 10 }; 11 11 12 12 int i2c_pca_add_bus(struct i2c_adapter *); 13 - int i2c_pca_del_bus(struct i2c_adapter *); 14 13 15 14 #endif /* _LINUX_I2C_ALGO_PCA_H */
+1 -2
include/linux/i2c-algo-pcf.h
··· 31 31 int (*getpcf) (void *data, int ctl); 32 32 int (*getown) (void *data); 33 33 int (*getclock) (void *data); 34 - void (*waitforpin) (void); 34 + void (*waitforpin) (void); 35 35 36 36 /* local settings */ 37 37 int udelay; ··· 39 39 }; 40 40 41 41 int i2c_pcf_add_bus(struct i2c_adapter *); 42 - int i2c_pcf_del_bus(struct i2c_adapter *); 43 42 44 43 #endif /* _LINUX_I2C_ALGO_PCF_H */
-1
include/linux/i2c-algo-sgi.h
··· 22 22 }; 23 23 24 24 int i2c_sgi_add_bus(struct i2c_adapter *); 25 - int i2c_sgi_del_bus(struct i2c_adapter *); 26 25 27 26 #endif /* I2C_ALGO_SGI_H */
+6 -11
include/linux/i2c-id.h
··· 1 1 /* ------------------------------------------------------------------------- */ 2 - /* */ 2 + /* */ 3 3 /* i2c-id.h - identifier values for i2c drivers and adapters */ 4 - /* */ 4 + /* */ 5 5 /* ------------------------------------------------------------------------- */ 6 6 /* Copyright (C) 1995-1999 Simon G. Vogl 7 7 ··· 40 40 #define I2C_DRIVERID_SAA7120 11 /* video encoder */ 41 41 #define I2C_DRIVERID_SAA7121 12 /* video encoder */ 42 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 44 #define I2C_DRIVERID_PCF8574A 15 /* i2c expander - 8 bit in/out */ 45 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 47 #define I2C_DRIVERID_TEA6300 18 /* audio mixer */ 48 48 #define I2C_DRIVERID_BT829 19 /* pc to tv encoder */ 49 49 #define I2C_DRIVERID_TDA9850 20 /* audio mixer */ ··· 82 82 #define I2C_DRIVERID_STM41T00 52 /* real time clock */ 83 83 #define I2C_DRIVERID_UDA1342 53 /* UDA1342 audio codec */ 84 84 #define I2C_DRIVERID_ADV7170 54 /* video encoder */ 85 - #define I2C_DRIVERID_RADEON 55 /* I2C bus on Radeon boards */ 86 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 87 #define I2C_DRIVERID_INDYCAM 58 /* SGI IndyCam */ 89 88 #define I2C_DRIVERID_BT832 59 /* CMOS camera video processor */ 90 89 #define I2C_DRIVERID_TDA9887 60 /* TDA988x IF-PLL demodulator */ ··· 131 132 #define I2C_DRIVERID_ADM1021 1008 132 133 #define I2C_DRIVERID_ADM9240 1009 133 134 #define I2C_DRIVERID_LTC1710 1010 134 - #define I2C_DRIVERID_ICSPLL 1012 135 135 #define I2C_DRIVERID_BT869 1013 136 136 #define I2C_DRIVERID_MAXILIFE 1014 137 137 #define I2C_DRIVERID_MATORB 1015 ··· 163 165 * ---- Adapter types ---------------------------------------------------- 164 166 */ 165 167 166 - /* --- Bit algorithm adapters */ 168 + /* --- Bit algorithm adapters */ 167 169 #define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */ 168 170 #define I2C_HW_B_SER 0x010002 /* Serial line interface */ 169 171 #define I2C_HW_B_BT848 0x010005 /* BT848 video boards */ ··· 210 212 211 213 /* --- MPC8xx PowerPC adapters */ 212 214 #define I2C_HW_MPC8XX_EPON 0x110000 /* Eponymous MPC8xx I2C adapter */ 213 - 214 - /* --- ITE based algorithms */ 215 - #define I2C_HW_I_IIC 0x080000 /* controller on the ITE */ 216 215 217 216 /* --- PowerPC on-chip adapters */ 218 217 #define I2C_HW_OCP 0x120000 /* IBM on-chip I2C adapter */
+43
include/linux/i2c-pnx.h
··· 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__ */
+38 -37
include/linux/i2c.h
··· 1 1 /* ------------------------------------------------------------------------- */ 2 - /* */ 2 + /* */ 3 3 /* i2c.h - definitions for the i2c-bus interface */ 4 - /* */ 4 + /* */ 5 5 /* ------------------------------------------------------------------------- */ 6 6 /* Copyright (C) 1995-2000 Simon G. Vogl 7 7 ··· 27 27 #define _LINUX_I2C_H 28 28 29 29 #include <linux/types.h> 30 - #ifdef __KERNEL__ 30 + #ifdef __KERNEL__ 31 31 #include <linux/module.h> 32 32 #include <linux/i2c-id.h> 33 33 #include <linux/mod_devicetable.h> ··· 53 53 54 54 /* 55 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 57 - * transmit one message at a time, a more complex version can be used 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 58 58 * transmit an arbitrary number of messages without interruption. 59 59 */ 60 60 extern int i2c_master_send(struct i2c_client *,const char* ,int); ··· 67 67 68 68 /* This is the very generalized SMBus access routine. You probably do not 69 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 71 Note that we use i2c_adapter here, because you do not need a specific 72 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 74 unsigned short flags, 75 75 char read_write, u8 command, int size, 76 76 union i2c_smbus_data * data); ··· 112 112 113 113 /* Notifies the driver that a new bus has appeared. This routine 114 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 116 * registers the client(s) that are on the bus to the i2c admin. via 117 117 * i2c_attach_client. 118 118 */ 119 119 int (*attach_adapter)(struct i2c_adapter *); 120 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 123 * the chance to remove its private data. Also, if the client struct 124 124 * has been dynamically allocated by the driver in the function above, 125 125 * it must be freed here. ··· 139 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 143 * i2c bus. The behaviour is defined by the routines of the driver. This 144 144 * function is mainly used for lookup & other admin. functions. 145 145 */ 146 146 struct i2c_client { 147 147 unsigned int flags; /* div., see below */ 148 - unsigned short addr; /* chip address - NOTE: 7bit */ 148 + unsigned short addr; /* chip address - NOTE: 7bit */ 149 149 /* addresses are stored in the */ 150 150 /* _LOWER_ 7 bits */ 151 151 struct i2c_adapter *adapter; /* the adapter we sit on */ ··· 182 182 */ 183 183 struct i2c_algorithm { 184 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 186 smbus_xfer. If set to NULL, the SMBus protocol is simulated 187 187 using common I2C messages */ 188 188 /* master_xfer should return the number of messages successfully 189 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 191 int num); 192 - int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, 192 + int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, 193 193 unsigned short flags, char read_write, 194 194 u8 command, int size, union i2c_smbus_data * data); 195 195 ··· 216 216 int (*client_unregister)(struct i2c_client *); 217 217 218 218 /* data fields that are valid for all devices */ 219 + u8 level; /* nesting level for lockdep */ 219 220 struct mutex bus_lock; 220 221 struct mutex clist_lock; 221 222 ··· 317 316 * It will only call found_proc if some client is connected at the 318 317 * specific address (unless a 'force' matched); 319 318 */ 320 - extern int i2c_probe(struct i2c_adapter *adapter, 319 + extern int i2c_probe(struct i2c_adapter *adapter, 321 320 struct i2c_client_address_data *address_data, 322 321 int (*found_proc) (struct i2c_adapter *, int, int)); 323 322 ··· 353 352 */ 354 353 struct i2c_msg { 355 354 __u16 addr; /* slave address */ 356 - __u16 flags; 355 + __u16 flags; 357 356 #define I2C_M_TEN 0x10 /* we have a ten bit chip address */ 358 357 #define I2C_M_RD 0x01 359 358 #define I2C_M_NOSTART 0x4000 360 359 #define I2C_M_REV_DIR_ADDR 0x2000 361 360 #define I2C_M_IGNORE_NAK 0x1000 362 361 #define I2C_M_NO_RD_ACK 0x0800 363 - __u16 len; /* msg length */ 364 - __u8 *buf; /* pointer to msg data */ 362 + __u16 len; /* msg length */ 363 + __u8 *buf; /* pointer to msg data */ 365 364 }; 366 365 367 366 /* To determine what functionality is present */ ··· 371 370 #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ 372 371 #define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */ 373 372 #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ 374 - #define I2C_FUNC_SMBUS_QUICK 0x00010000 375 - #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 376 - #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 377 - #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 378 - #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 379 - #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 380 - #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 381 - #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 382 - #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 383 - #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 373 + #define I2C_FUNC_SMBUS_QUICK 0x00010000 374 + #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 375 + #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 376 + #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 377 + #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 378 + #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 379 + #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 380 + #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 381 + #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 382 + #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 384 383 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ 385 384 #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ 386 385 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */ ··· 407 406 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ 408 407 I2C_FUNC_SMBUS_I2C_BLOCK) 409 408 410 - /* 411 - * Data for SMBus Messages 409 + /* 410 + * Data for SMBus Messages 412 411 */ 413 - #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ 412 + #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ 414 413 union i2c_smbus_data { 415 414 __u8 byte; 416 415 __u16 word; ··· 422 421 #define I2C_SMBUS_READ 1 423 422 #define I2C_SMBUS_WRITE 0 424 423 425 - /* SMBus transaction types (size parameter in the above functions) 424 + /* SMBus transaction types (size parameter in the above functions) 426 425 Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ 427 426 #define I2C_SMBUS_QUICK 0 428 427 #define I2C_SMBUS_BYTE 1 429 - #define I2C_SMBUS_BYTE_DATA 2 428 + #define I2C_SMBUS_BYTE_DATA 2 430 429 #define I2C_SMBUS_WORD_DATA 3 431 430 #define I2C_SMBUS_PROC_CALL 4 432 431 #define I2C_SMBUS_BLOCK_DATA 5 ··· 435 434 436 435 437 436 /* ----- commands for the ioctl like i2c_command call: 438 - * note that additional calls are defined in the algorithm and hw 439 - * dependent layers - these can be listed here, or see the 437 + * note that additional calls are defined in the algorithm and hw 438 + * dependent layers - these can be listed here, or see the 440 439 * corresponding header files. 441 440 */ 442 441 /* -> bit-adapter specific ioctls */ 443 442 #define I2C_RETRIES 0x0701 /* number of times a device address */ 444 443 /* should be polled when not */ 445 - /* acknowledging */ 446 - #define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ 444 + /* acknowledging */ 445 + #define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ 447 446 448 447 449 448 /* this is for i2c-dev.c */