Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus/2639/i2c-2' of git://git.fluff.org/bjdooks/linux

* 'for-linus/2639/i2c-2' of git://git.fluff.org/bjdooks/linux:
i2c-pxa2xx: Don't clear isr bits too early
i2c-pxa2xx: Fix register offsets
i2c-pxa2xx: pass of_node from platform driver to adapter and publish
i2c-pxa2xx: check timeout correctly
i2c-pxa2xx: add support for shared IRQ handler
i2c-pxa2xx: Add PCI support for PXA I2C controller
ARM: pxa2xx: reorganize I2C files
i2c-pxa2xx: use dynamic register layout
i2c-mxs: set controller to pio queue mode after reset
i2c-eg20t: support new device OKI SEMICONDUCTOR ML7213 IOH
i2c/busses: Add support for Diolan U2C-12 USB-I2C adapter

+996 -147
+26
Documentation/i2c/busses/i2c-diolan-u2c
··· 1 + Kernel driver i2c-diolan-u2c 2 + 3 + Supported adapters: 4 + * Diolan U2C-12 I2C-USB adapter 5 + Documentation: 6 + http://www.diolan.com/i2c/u2c12.html 7 + 8 + Author: Guenter Roeck <guenter.roeck@ericsson.com> 9 + 10 + Description 11 + ----------- 12 + 13 + This is the driver for the Diolan U2C-12 USB-I2C adapter. 14 + 15 + The Diolan U2C-12 I2C-USB Adapter provides a low cost solution to connect 16 + a computer to I2C slave devices using a USB interface. It also supports 17 + connectivity to SPI devices. 18 + 19 + This driver only supports the I2C interface of U2C-12. The driver does not use 20 + interrupts. 21 + 22 + 23 + Module parameters 24 + ----------------- 25 + 26 + * frequency: I2C bus frequency
+6
MAINTAINERS
··· 2138 2138 F: drivers/char/epca* 2139 2139 F: drivers/char/digi* 2140 2140 2141 + DIOLAN U2C-12 I2C DRIVER 2142 + M: Guenter Roeck <guenter.roeck@ericsson.com> 2143 + L: linux-i2c@vger.kernel.org 2144 + S: Maintained 2145 + F: drivers/i2c/busses/i2c-diolan-u2c.c 2146 + 2141 2147 DIRECTORY NOTIFICATION (DNOTIFY) 2142 2148 M: Eric Paris <eparis@parisplace.org> 2143 2149 S: Maintained
+1 -1
arch/arm/mach-mmp/include/mach/mmp2.h
··· 11 11 extern void mmp2_clear_pmic_int(void); 12 12 13 13 #include <linux/i2c.h> 14 + #include <linux/i2c/pxa-i2c.h> 14 15 #include <mach/devices.h> 15 - #include <plat/i2c.h> 16 16 17 17 extern struct pxa_device_desc mmp2_device_uart1; 18 18 extern struct pxa_device_desc mmp2_device_uart2;
+1 -1
arch/arm/mach-mmp/include/mach/pxa168.h
··· 8 8 extern void pxa168_clear_keypad_wakeup(void); 9 9 10 10 #include <linux/i2c.h> 11 + #include <linux/i2c/pxa-i2c.h> 11 12 #include <mach/devices.h> 12 - #include <plat/i2c.h> 13 13 #include <plat/pxa3xx_nand.h> 14 14 #include <video/pxa168fb.h> 15 15 #include <plat/pxa27x_keypad.h>
+1 -1
arch/arm/mach-mmp/include/mach/pxa910.h
··· 7 7 extern void __init pxa910_init_irq(void); 8 8 9 9 #include <linux/i2c.h> 10 + #include <linux/i2c/pxa-i2c.h> 10 11 #include <mach/devices.h> 11 - #include <plat/i2c.h> 12 12 #include <plat/pxa3xx_nand.h> 13 13 14 14 extern struct pxa_device_desc pxa910_device_uart1;
+1 -2
arch/arm/mach-pxa/balloon3.c
··· 27 27 #include <linux/mtd/partitions.h> 28 28 #include <linux/types.h> 29 29 #include <linux/i2c/pcf857x.h> 30 + #include <linux/i2c/pxa-i2c.h> 30 31 #include <linux/mtd/nand.h> 31 32 #include <linux/mtd/physmap.h> 32 33 #include <linux/regulator/max1586.h> ··· 51 50 #include <mach/pxa27x-udc.h> 52 51 #include <mach/irda.h> 53 52 #include <mach/ohci.h> 54 - 55 - #include <plat/i2c.h> 56 53 57 54 #include "generic.h" 58 55 #include "devices.h"
+1 -1
arch/arm/mach-pxa/cm-x300.c
··· 29 29 30 30 #include <linux/i2c.h> 31 31 #include <linux/i2c/pca953x.h> 32 + #include <linux/i2c/pxa-i2c.h> 32 33 33 34 #include <linux/mfd/da903x.h> 34 35 #include <linux/regulator/machine.h> ··· 49 48 #include <mach/pxafb.h> 50 49 #include <mach/mmc.h> 51 50 #include <mach/ohci.h> 52 - #include <plat/i2c.h> 53 51 #include <plat/pxa3xx_nand.h> 54 52 #include <mach/audio.h> 55 53 #include <mach/pxa3xx-u2d.h>
+1 -2
arch/arm/mach-pxa/colibri-evalboard.c
··· 20 20 #include <mach/hardware.h> 21 21 #include <asm/mach/arch.h> 22 22 #include <linux/i2c.h> 23 + #include <linux/i2c/pxa-i2c.h> 23 24 24 25 #include <mach/pxa27x.h> 25 26 #include <mach/colibri.h> 26 27 #include <mach/mmc.h> 27 28 #include <mach/ohci.h> 28 29 #include <mach/pxa27x-udc.h> 29 - 30 - #include <plat/i2c.h> 31 30 32 31 #include "generic.h" 33 32 #include "devices.h"
+1 -2
arch/arm/mach-pxa/colibri-pxa270-income.c
··· 21 21 #include <linux/kernel.h> 22 22 #include <linux/platform_device.h> 23 23 #include <linux/pwm_backlight.h> 24 + #include <linux/i2c/pxa-i2c.h> 24 25 #include <linux/sysdev.h> 25 26 26 27 #include <asm/irq.h> ··· 33 32 #include <mach/pxa27x.h> 34 33 #include <mach/pxa27x-udc.h> 35 34 #include <mach/pxafb.h> 36 - 37 - #include <plat/i2c.h> 38 35 39 36 #include "devices.h" 40 37 #include "generic.h"
+1 -1
arch/arm/mach-pxa/corgi.c
··· 24 24 #include <linux/gpio.h> 25 25 #include <linux/backlight.h> 26 26 #include <linux/i2c.h> 27 + #include <linux/i2c/pxa-i2c.h> 27 28 #include <linux/io.h> 28 29 #include <linux/spi/spi.h> 29 30 #include <linux/spi/ads7846.h> ··· 46 45 #include <asm/mach/irq.h> 47 46 48 47 #include <mach/pxa25x.h> 49 - #include <plat/i2c.h> 50 48 #include <mach/irda.h> 51 49 #include <mach/mmc.h> 52 50 #include <mach/udc.h>
+1 -1
arch/arm/mach-pxa/csb726.c
··· 17 17 #include <linux/mtd/partitions.h> 18 18 #include <linux/sm501.h> 19 19 #include <linux/smsc911x.h> 20 + #include <linux/i2c/pxa-i2c.h> 20 21 21 22 #include <asm/mach-types.h> 22 23 #include <asm/mach/arch.h> 23 24 #include <mach/csb726.h> 24 25 #include <mach/mfp-pxa27x.h> 25 - #include <plat/i2c.h> 26 26 #include <mach/mmc.h> 27 27 #include <mach/ohci.h> 28 28 #include <mach/pxa2xx-regs.h>
+1 -1
arch/arm/mach-pxa/devices.c
··· 4 4 #include <linux/platform_device.h> 5 5 #include <linux/dma-mapping.h> 6 6 #include <linux/spi/pxa2xx_spi.h> 7 + #include <linux/i2c/pxa-i2c.h> 7 8 8 9 #include <asm/pmu.h> 9 10 #include <mach/udc.h> ··· 17 16 #include <mach/camera.h> 18 17 #include <mach/audio.h> 19 18 #include <mach/hardware.h> 20 - #include <plat/i2c.h> 21 19 #include <plat/pxa3xx_nand.h> 22 20 23 21 #include "devices.h"
+1 -1
arch/arm/mach-pxa/em-x270.c
··· 31 31 #include <linux/apm-emulation.h> 32 32 #include <linux/i2c.h> 33 33 #include <linux/i2c/pca953x.h> 34 + #include <linux/i2c/pxa-i2c.h> 34 35 #include <linux/regulator/userspace-consumer.h> 35 36 36 37 #include <media/soc_camera.h> ··· 46 45 #include <mach/ohci.h> 47 46 #include <mach/mmc.h> 48 47 #include <plat/pxa27x_keypad.h> 49 - #include <plat/i2c.h> 50 48 #include <mach/camera.h> 51 49 52 50 #include "generic.h"
+1 -1
arch/arm/mach-pxa/ezx.c
··· 20 20 #include <linux/gpio.h> 21 21 #include <linux/gpio_keys.h> 22 22 #include <linux/leds-lp3944.h> 23 + #include <linux/i2c/pxa-i2c.h> 23 24 24 25 #include <media/soc_camera.h> 25 26 ··· 31 30 #include <mach/pxa27x.h> 32 31 #include <mach/pxafb.h> 33 32 #include <mach/ohci.h> 34 - #include <plat/i2c.h> 35 33 #include <mach/hardware.h> 36 34 #include <plat/pxa27x_keypad.h> 37 35 #include <mach/camera.h>
+1 -1
arch/arm/mach-pxa/hx4700.c
··· 35 35 #include <linux/spi/spi.h> 36 36 #include <linux/spi/pxa2xx_spi.h> 37 37 #include <linux/usb/gpio_vbus.h> 38 + #include <linux/i2c/pxa-i2c.h> 38 39 39 40 #include <mach/hardware.h> 40 41 #include <asm/mach-types.h> ··· 43 42 44 43 #include <mach/pxa27x.h> 45 44 #include <mach/hx4700.h> 46 - #include <plat/i2c.h> 47 45 #include <mach/irda.h> 48 46 49 47 #include <video/platform_lcd.h>
+1 -1
arch/arm/mach-pxa/littleton.c
··· 28 28 #include <linux/leds.h> 29 29 #include <linux/mfd/da903x.h> 30 30 #include <linux/i2c/max732x.h> 31 + #include <linux/i2c/pxa-i2c.h> 31 32 32 33 #include <asm/types.h> 33 34 #include <asm/setup.h> ··· 46 45 #include <mach/mmc.h> 47 46 #include <plat/pxa27x_keypad.h> 48 47 #include <mach/littleton.h> 49 - #include <plat/i2c.h> 50 48 #include <plat/pxa3xx_nand.h> 51 49 52 50 #include "generic.h"
+1 -1
arch/arm/mach-pxa/magician.c
··· 28 28 #include <linux/regulator/bq24022.h> 29 29 #include <linux/regulator/machine.h> 30 30 #include <linux/usb/gpio_vbus.h> 31 + #include <linux/i2c/pxa-i2c.h> 31 32 32 33 #include <mach/hardware.h> 33 34 #include <asm/mach-types.h> ··· 37 36 #include <mach/pxa27x.h> 38 37 #include <mach/magician.h> 39 38 #include <mach/pxafb.h> 40 - #include <plat/i2c.h> 41 39 #include <mach/mmc.h> 42 40 #include <mach/irda.h> 43 41 #include <mach/ohci.h>
+1 -1
arch/arm/mach-pxa/mainstone.c
··· 27 27 #include <linux/gpio_keys.h> 28 28 #include <linux/pwm_backlight.h> 29 29 #include <linux/smc91x.h> 30 + #include <linux/i2c/pxa-i2c.h> 30 31 31 32 #include <asm/types.h> 32 33 #include <asm/setup.h> ··· 47 46 #include <mach/mainstone.h> 48 47 #include <mach/audio.h> 49 48 #include <mach/pxafb.h> 50 - #include <plat/i2c.h> 51 49 #include <mach/mmc.h> 52 50 #include <mach/irda.h> 53 51 #include <mach/ohci.h>
+1 -1
arch/arm/mach-pxa/mioa701.c
··· 39 39 #include <linux/usb/gpio_vbus.h> 40 40 #include <linux/regulator/max1586.h> 41 41 #include <linux/slab.h> 42 + #include <linux/i2c/pxa-i2c.h> 42 43 43 44 #include <asm/mach-types.h> 44 45 #include <asm/mach/arch.h> ··· 51 50 #include <mach/mmc.h> 52 51 #include <mach/udc.h> 53 52 #include <mach/pxa27x-udc.h> 54 - #include <plat/i2c.h> 55 53 #include <mach/camera.h> 56 54 #include <mach/audio.h> 57 55 #include <media/soc_camera.h>
+1 -1
arch/arm/mach-pxa/mxm8x10.c
··· 22 22 #include <linux/serial_8250.h> 23 23 #include <linux/dm9000.h> 24 24 #include <linux/gpio.h> 25 + #include <linux/i2c/pxa-i2c.h> 25 26 26 - #include <plat/i2c.h> 27 27 #include <plat/pxa3xx_nand.h> 28 28 29 29 #include <mach/pxafb.h>
+1 -2
arch/arm/mach-pxa/palm27x.c
··· 22 22 #include <linux/power_supply.h> 23 23 #include <linux/usb/gpio_vbus.h> 24 24 #include <linux/regulator/max1586.h> 25 + #include <linux/i2c/pxa-i2c.h> 25 26 26 27 #include <asm/mach-types.h> 27 28 #include <asm/mach/arch.h> ··· 36 35 #include <mach/udc.h> 37 36 #include <mach/palmasoc.h> 38 37 #include <mach/palm27x.h> 39 - 40 - #include <plat/i2c.h> 41 38 42 39 #include "generic.h" 43 40 #include "devices.h"
+1 -1
arch/arm/mach-pxa/pcm990-baseboard.c
··· 23 23 #include <linux/irq.h> 24 24 #include <linux/platform_device.h> 25 25 #include <linux/i2c.h> 26 + #include <linux/i2c/pxa-i2c.h> 26 27 #include <linux/pwm_backlight.h> 27 28 28 29 #include <media/soc_camera.h> 29 30 30 31 #include <asm/gpio.h> 31 - #include <plat/i2c.h> 32 32 #include <mach/camera.h> 33 33 #include <asm/mach/map.h> 34 34 #include <mach/pxa27x.h>
+1 -1
arch/arm/mach-pxa/poodle.c
··· 23 23 #include <linux/mtd/physmap.h> 24 24 #include <linux/gpio.h> 25 25 #include <linux/i2c.h> 26 + #include <linux/i2c/pxa-i2c.h> 26 27 #include <linux/spi/spi.h> 27 28 #include <linux/spi/ads7846.h> 28 29 #include <linux/spi/pxa2xx_spi.h> ··· 45 44 #include <mach/irda.h> 46 45 #include <mach/poodle.h> 47 46 #include <mach/pxafb.h> 48 - #include <plat/i2c.h> 49 47 50 48 #include <asm/hardware/scoop.h> 51 49 #include <asm/hardware/locomo.h>
+1 -2
arch/arm/mach-pxa/pxa27x.c
··· 19 19 #include <linux/sysdev.h> 20 20 #include <linux/io.h> 21 21 #include <linux/irq.h> 22 + #include <linux/i2c/pxa-i2c.h> 22 23 23 24 #include <asm/mach/map.h> 24 25 #include <mach/hardware.h> ··· 32 31 #include <mach/pm.h> 33 32 #include <mach/dma.h> 34 33 #include <mach/smemc.h> 35 - 36 - #include <plat/i2c.h> 37 34 38 35 #include "generic.h" 39 36 #include "devices.h"
+1 -1
arch/arm/mach-pxa/pxa3xx.c
··· 21 21 #include <linux/irq.h> 22 22 #include <linux/io.h> 23 23 #include <linux/sysdev.h> 24 + #include <linux/i2c/pxa-i2c.h> 24 25 25 26 #include <asm/mach/map.h> 26 27 #include <mach/hardware.h> ··· 33 32 #include <mach/dma.h> 34 33 #include <mach/regs-intc.h> 35 34 #include <mach/smemc.h> 36 - #include <plat/i2c.h> 37 35 38 36 #include "generic.h" 39 37 #include "devices.h"
+1 -1
arch/arm/mach-pxa/pxa95x.c
··· 15 15 #include <linux/init.h> 16 16 #include <linux/pm.h> 17 17 #include <linux/platform_device.h> 18 + #include <linux/i2c/pxa-i2c.h> 18 19 #include <linux/irq.h> 19 20 #include <linux/io.h> 20 21 #include <linux/sysdev.h> ··· 28 27 #include <mach/pm.h> 29 28 #include <mach/dma.h> 30 29 #include <mach/regs-intc.h> 31 - #include <plat/i2c.h> 32 30 33 31 #include "generic.h" 34 32 #include "devices.h"
+1 -1
arch/arm/mach-pxa/raumfeld.c
··· 32 32 #include <linux/sched.h> 33 33 #include <linux/pwm_backlight.h> 34 34 #include <linux/i2c.h> 35 + #include <linux/i2c/pxa-i2c.h> 35 36 #include <linux/spi/spi.h> 36 37 #include <linux/spi/spi_gpio.h> 37 38 #include <linux/lis3lv02d.h> ··· 54 53 #include <mach/ohci.h> 55 54 #include <mach/pxafb.h> 56 55 #include <mach/mmc.h> 57 - #include <plat/i2c.h> 58 56 #include <plat/pxa3xx_nand.h> 59 57 60 58 #include "generic.h"
+1 -1
arch/arm/mach-pxa/saar.c
··· 20 20 #include <linux/delay.h> 21 21 #include <linux/fb.h> 22 22 #include <linux/i2c.h> 23 + #include <linux/i2c/pxa-i2c.h> 23 24 #include <linux/smc91x.h> 24 25 #include <linux/mfd/da903x.h> 25 26 #include <linux/mtd/mtd.h> ··· 32 31 #include <asm/mach/flash.h> 33 32 34 33 #include <mach/pxa930.h> 35 - #include <plat/i2c.h> 36 34 #include <mach/pxafb.h> 37 35 38 36 #include "devices.h"
+1 -2
arch/arm/mach-pxa/saarb.c
··· 13 13 #include <linux/init.h> 14 14 #include <linux/kernel.h> 15 15 #include <linux/i2c.h> 16 + #include <linux/i2c/pxa-i2c.h> 16 17 #include <linux/mfd/88pm860x.h> 17 18 18 19 #include <asm/mach-types.h> ··· 24 23 #include <mach/mfp.h> 25 24 #include <mach/mfp-pxa930.h> 26 25 #include <mach/gpio.h> 27 - 28 - #include <plat/i2c.h> 29 26 30 27 #include "generic.h" 31 28
+1 -2
arch/arm/mach-pxa/spitz.c
··· 19 19 #include <linux/gpio.h> 20 20 #include <linux/leds.h> 21 21 #include <linux/i2c.h> 22 + #include <linux/i2c/pxa-i2c.h> 22 23 #include <linux/i2c/pca953x.h> 23 24 #include <linux/spi/spi.h> 24 25 #include <linux/spi/ads7846.h> ··· 47 46 #include <mach/spitz.h> 48 47 #include <mach/sharpsl_pm.h> 49 48 #include <mach/smemc.h> 50 - 51 - #include <plat/i2c.h> 52 49 53 50 #include "generic.h" 54 51 #include "devices.h"
+1 -1
arch/arm/mach-pxa/stargate2.c
··· 25 25 #include <linux/mtd/plat-ram.h> 26 26 #include <linux/mtd/partitions.h> 27 27 28 + #include <linux/i2c/pxa-i2c.h> 28 29 #include <linux/i2c/pcf857x.h> 29 30 #include <linux/i2c/at24.h> 30 31 #include <linux/smc91x.h> ··· 44 43 #include <asm/mach/flash.h> 45 44 46 45 #include <mach/pxa27x.h> 47 - #include <plat/i2c.h> 48 46 #include <mach/mmc.h> 49 47 #include <mach/udc.h> 50 48 #include <mach/pxa27x-udc.h>
+1 -2
arch/arm/mach-pxa/tavorevb3.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/interrupt.h> 17 17 #include <linux/i2c.h> 18 + #include <linux/i2c/pxa-i2c.h> 18 19 #include <linux/gpio.h> 19 20 #include <linux/mfd/88pm860x.h> 20 21 ··· 23 22 #include <asm/mach/arch.h> 24 23 25 24 #include <mach/pxa930.h> 26 - 27 - #include <plat/i2c.h> 28 25 29 26 #include "devices.h" 30 27 #include "generic.h"
+1 -1
arch/arm/mach-pxa/tosa.c
··· 34 34 #include <linux/spi/spi.h> 35 35 #include <linux/spi/pxa2xx_spi.h> 36 36 #include <linux/input/matrix_keypad.h> 37 + #include <linux/i2c/pxa-i2c.h> 37 38 38 39 #include <asm/setup.h> 39 40 #include <asm/mach-types.h> ··· 42 41 #include <mach/pxa25x.h> 43 42 #include <mach/reset.h> 44 43 #include <mach/irda.h> 45 - #include <plat/i2c.h> 46 44 #include <mach/mmc.h> 47 45 #include <mach/udc.h> 48 46 #include <mach/tosa_bt.h>
+1 -1
arch/arm/mach-pxa/trizeps4.c
··· 26 26 #include <linux/dm9000.h> 27 27 #include <linux/mtd/physmap.h> 28 28 #include <linux/mtd/partitions.h> 29 + #include <linux/i2c/pxa-i2c.h> 29 30 30 31 #include <asm/types.h> 31 32 #include <asm/setup.h> ··· 48 47 #include <mach/irda.h> 49 48 #include <mach/ohci.h> 50 49 #include <mach/smemc.h> 51 - #include <plat/i2c.h> 52 50 53 51 #include "generic.h" 54 52 #include "devices.h"
+1 -1
arch/arm/mach-pxa/viper.c
··· 36 36 #include <linux/gpio.h> 37 37 #include <linux/jiffies.h> 38 38 #include <linux/i2c-gpio.h> 39 + #include <linux/i2c/pxa-i2c.h> 39 40 #include <linux/serial_8250.h> 40 41 #include <linux/smc91x.h> 41 42 #include <linux/pwm_backlight.h> ··· 48 47 #include <mach/pxa25x.h> 49 48 #include <mach/audio.h> 50 49 #include <mach/pxafb.h> 51 - #include <plat/i2c.h> 52 50 #include <mach/regs-uart.h> 53 51 #include <mach/arcom-pcmcia.h> 54 52 #include <mach/viper.h>
+1 -2
arch/arm/mach-pxa/vpac270.c
··· 26 26 #include <linux/ucb1400.h> 27 27 #include <linux/ata_platform.h> 28 28 #include <linux/regulator/max1586.h> 29 + #include <linux/i2c/pxa-i2c.h> 29 30 30 31 #include <asm/mach-types.h> 31 32 #include <asm/mach/arch.h> ··· 40 39 #include <mach/pxa27x-udc.h> 41 40 #include <mach/udc.h> 42 41 #include <mach/pata_pxa.h> 43 - 44 - #include <plat/i2c.h> 45 42 46 43 #include "generic.h" 47 44 #include "devices.h"
+1 -2
arch/arm/mach-pxa/xcep.c
··· 16 16 17 17 #include <linux/platform_device.h> 18 18 #include <linux/i2c.h> 19 + #include <linux/i2c/pxa-i2c.h> 19 20 #include <linux/smc91x.h> 20 21 #include <linux/mtd/mtd.h> 21 22 #include <linux/mtd/partitions.h> ··· 26 25 #include <asm/mach/arch.h> 27 26 #include <asm/mach/irq.h> 28 27 #include <asm/mach/map.h> 29 - 30 - #include <plat/i2c.h> 31 28 32 29 #include <mach/hardware.h> 33 30 #include <mach/pxa2xx-regs.h>
+1 -2
arch/arm/mach-pxa/z2.c
··· 29 29 #include <linux/gpio_keys.h> 30 30 #include <linux/delay.h> 31 31 #include <linux/regulator/machine.h> 32 + #include <linux/i2c/pxa-i2c.h> 32 33 33 34 #include <asm/mach-types.h> 34 35 #include <asm/mach/arch.h> ··· 40 39 #include <mach/pxafb.h> 41 40 #include <mach/mmc.h> 42 41 #include <plat/pxa27x_keypad.h> 43 - 44 - #include <plat/i2c.h> 45 42 46 43 #include "generic.h" 47 44 #include "devices.h"
+1 -2
arch/arm/mach-pxa/zeus.c
··· 25 25 #include <linux/mtd/partitions.h> 26 26 #include <linux/mtd/physmap.h> 27 27 #include <linux/i2c.h> 28 + #include <linux/i2c/pxa-i2c.h> 28 29 #include <linux/i2c/pca953x.h> 29 30 #include <linux/apm-emulation.h> 30 31 #include <linux/can/platform/mcp251x.h> ··· 33 32 #include <asm/mach-types.h> 34 33 #include <asm/mach/arch.h> 35 34 #include <asm/mach/map.h> 36 - 37 - #include <plat/i2c.h> 38 35 39 36 #include <mach/pxa2xx-regs.h> 40 37 #include <mach/regs-uart.h>
+1 -1
arch/arm/mach-pxa/zylonite_pxa300.c
··· 17 17 #include <linux/kernel.h> 18 18 #include <linux/init.h> 19 19 #include <linux/i2c.h> 20 + #include <linux/i2c/pxa-i2c.h> 20 21 #include <linux/i2c/pca953x.h> 21 22 #include <linux/gpio.h> 22 23 23 24 #include <mach/pxa300.h> 24 - #include <plat/i2c.h> 25 25 #include <mach/zylonite.h> 26 26 27 27 #include "generic.h"
arch/arm/plat-pxa/include/plat/i2c.h include/linux/i2c/pxa-i2c.h
+24 -8
drivers/i2c/busses/Kconfig
··· 547 547 548 548 config I2C_PXA 549 549 tristate "Intel PXA2XX I2C adapter" 550 - depends on ARCH_PXA || ARCH_MMP 550 + depends on ARCH_PXA || ARCH_MMP || (X86_32 && PCI && OF) 551 551 help 552 552 If you have devices in the PXA I2C bus, say yes to this option. 553 553 This driver can also be built as a module. If so, the module 554 554 will be called i2c-pxa. 555 555 556 + config I2C_PXA_PCI 557 + def_bool I2C_PXA && X86_32 && PCI && OF 558 + 556 559 config I2C_PXA_SLAVE 557 560 bool "Intel PXA2XX I2C Slave comms support" 558 - depends on I2C_PXA 561 + depends on I2C_PXA && !X86_32 559 562 help 560 563 Support I2C slave mode communications on the PXA I2C bus. This 561 564 is necessary for systems where the PXA may be a target on the ··· 671 668 will be called xilinx_i2c. 672 669 673 670 config I2C_EG20T 674 - tristate "PCH I2C of Intel EG20T" 675 - depends on PCI 676 - help 677 - This driver is for PCH(Platform controller Hub) I2C of EG20T which 678 - is an IOH(Input/Output Hub) for x86 embedded processor. 679 - This driver can access PCH I2C bus device. 671 + tristate "Intel EG20T PCH/OKI SEMICONDUCTOR ML7213 IOH" 672 + depends on PCI 673 + help 674 + This driver is for PCH(Platform controller Hub) I2C of EG20T which 675 + is an IOH(Input/Output Hub) for x86 embedded processor. 676 + This driver can access PCH I2C bus device. 677 + 678 + This driver also supports the ML7213, a companion chip for the 679 + Atom E6xx series and compatible with the Intel EG20T PCH. 680 680 681 681 comment "External I2C/SMBus adapter drivers" 682 + 683 + config I2C_DIOLAN_U2C 684 + tristate "Diolan U2C-12 USB adapter" 685 + depends on USB 686 + help 687 + If you say yes to this option, support will be included for Diolan 688 + U2C-12, a USB to I2C interface. 689 + 690 + This driver can also be built as a module. If so, the module 691 + will be called i2c-diolan-u2c. 682 692 683 693 config I2C_PARPORT 684 694 tristate "Parallel port adapter"
+2
drivers/i2c/busses/Makefile
··· 54 54 obj-$(CONFIG_I2C_PNX) += i2c-pnx.o 55 55 obj-$(CONFIG_I2C_PUV3) += i2c-puv3.o 56 56 obj-$(CONFIG_I2C_PXA) += i2c-pxa.o 57 + obj-$(CONFIG_I2C_PXA_PCI) += i2c-pxa-pci.o 57 58 obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o 58 59 obj-$(CONFIG_I2C_S6000) += i2c-s6000.o 59 60 obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o ··· 68 67 obj-$(CONFIG_I2C_EG20T) += i2c-eg20t.o 69 68 70 69 # External I2C/SMBus adapter drivers 70 + obj-$(CONFIG_I2C_DIOLAN_U2C) += i2c-diolan-u2c.o 71 71 obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o 72 72 obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o 73 73 obj-$(CONFIG_I2C_TAOS_EVM) += i2c-taos-evm.o
+535
drivers/i2c/busses/i2c-diolan-u2c.c
··· 1 + /* 2 + * Driver for the Diolan u2c-12 USB-I2C adapter 3 + * 4 + * Copyright (c) 2010-2011 Ericsson AB 5 + * 6 + * Derived from: 7 + * i2c-tiny-usb.c 8 + * Copyright (C) 2006-2007 Till Harbaum (Till@Harbaum.org) 9 + * 10 + * This program is free software; you can redistribute it and/or 11 + * modify it under the terms of the GNU General Public License as 12 + * published by the Free Software Foundation, version 2. 13 + */ 14 + 15 + #include <linux/kernel.h> 16 + #include <linux/errno.h> 17 + #include <linux/module.h> 18 + #include <linux/types.h> 19 + #include <linux/slab.h> 20 + #include <linux/usb.h> 21 + #include <linux/i2c.h> 22 + 23 + #define DRIVER_NAME "i2c-diolan-u2c" 24 + 25 + #define USB_VENDOR_ID_DIOLAN 0x0abf 26 + #define USB_DEVICE_ID_DIOLAN_U2C 0x3370 27 + 28 + #define DIOLAN_OUT_EP 0x02 29 + #define DIOLAN_IN_EP 0x84 30 + 31 + /* commands via USB, must match command ids in the firmware */ 32 + #define CMD_I2C_READ 0x01 33 + #define CMD_I2C_WRITE 0x02 34 + #define CMD_I2C_SCAN 0x03 /* Returns list of detected devices */ 35 + #define CMD_I2C_RELEASE_SDA 0x04 36 + #define CMD_I2C_RELEASE_SCL 0x05 37 + #define CMD_I2C_DROP_SDA 0x06 38 + #define CMD_I2C_DROP_SCL 0x07 39 + #define CMD_I2C_READ_SDA 0x08 40 + #define CMD_I2C_READ_SCL 0x09 41 + #define CMD_GET_FW_VERSION 0x0a 42 + #define CMD_GET_SERIAL 0x0b 43 + #define CMD_I2C_START 0x0c 44 + #define CMD_I2C_STOP 0x0d 45 + #define CMD_I2C_REPEATED_START 0x0e 46 + #define CMD_I2C_PUT_BYTE 0x0f 47 + #define CMD_I2C_GET_BYTE 0x10 48 + #define CMD_I2C_PUT_ACK 0x11 49 + #define CMD_I2C_GET_ACK 0x12 50 + #define CMD_I2C_PUT_BYTE_ACK 0x13 51 + #define CMD_I2C_GET_BYTE_ACK 0x14 52 + #define CMD_I2C_SET_SPEED 0x1b 53 + #define CMD_I2C_GET_SPEED 0x1c 54 + #define CMD_I2C_SET_CLK_SYNC 0x24 55 + #define CMD_I2C_GET_CLK_SYNC 0x25 56 + #define CMD_I2C_SET_CLK_SYNC_TO 0x26 57 + #define CMD_I2C_GET_CLK_SYNC_TO 0x27 58 + 59 + #define RESP_OK 0x00 60 + #define RESP_FAILED 0x01 61 + #define RESP_BAD_MEMADDR 0x04 62 + #define RESP_DATA_ERR 0x05 63 + #define RESP_NOT_IMPLEMENTED 0x06 64 + #define RESP_NACK 0x07 65 + #define RESP_TIMEOUT 0x09 66 + 67 + #define U2C_I2C_SPEED_FAST 0 /* 400 kHz */ 68 + #define U2C_I2C_SPEED_STD 1 /* 100 kHz */ 69 + #define U2C_I2C_SPEED_2KHZ 242 /* 2 kHz, minimum speed */ 70 + #define U2C_I2C_SPEED(f) ((DIV_ROUND_UP(1000000, (f)) - 10) / 2 + 1) 71 + 72 + #define U2C_I2C_FREQ_FAST 400000 73 + #define U2C_I2C_FREQ_STD 100000 74 + #define U2C_I2C_FREQ(s) (1000000 / (2 * (s - 1) + 10)) 75 + 76 + #define DIOLAN_USB_TIMEOUT 100 /* in ms */ 77 + #define DIOLAN_SYNC_TIMEOUT 20 /* in ms */ 78 + 79 + #define DIOLAN_OUTBUF_LEN 128 80 + #define DIOLAN_FLUSH_LEN (DIOLAN_OUTBUF_LEN - 4) 81 + #define DIOLAN_INBUF_LEN 256 /* Maximum supported receive length */ 82 + 83 + /* Structure to hold all of our device specific stuff */ 84 + struct i2c_diolan_u2c { 85 + u8 obuffer[DIOLAN_OUTBUF_LEN]; /* output buffer */ 86 + u8 ibuffer[DIOLAN_INBUF_LEN]; /* input buffer */ 87 + struct usb_device *usb_dev; /* the usb device for this device */ 88 + struct usb_interface *interface;/* the interface for this device */ 89 + struct i2c_adapter adapter; /* i2c related things */ 90 + int olen; /* Output buffer length */ 91 + int ocount; /* Number of enqueued messages */ 92 + }; 93 + 94 + static uint frequency = U2C_I2C_FREQ_STD; /* I2C clock frequency in Hz */ 95 + 96 + module_param(frequency, uint, S_IRUGO | S_IWUSR); 97 + MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz"); 98 + 99 + /* usb layer */ 100 + 101 + /* Send command to device, and get response. */ 102 + static int diolan_usb_transfer(struct i2c_diolan_u2c *dev) 103 + { 104 + int ret = 0; 105 + int actual; 106 + int i; 107 + 108 + if (!dev->olen || !dev->ocount) 109 + return -EINVAL; 110 + 111 + ret = usb_bulk_msg(dev->usb_dev, 112 + usb_sndbulkpipe(dev->usb_dev, DIOLAN_OUT_EP), 113 + dev->obuffer, dev->olen, &actual, 114 + DIOLAN_USB_TIMEOUT); 115 + if (!ret) { 116 + for (i = 0; i < dev->ocount; i++) { 117 + int tmpret; 118 + 119 + tmpret = usb_bulk_msg(dev->usb_dev, 120 + usb_rcvbulkpipe(dev->usb_dev, 121 + DIOLAN_IN_EP), 122 + dev->ibuffer, 123 + sizeof(dev->ibuffer), &actual, 124 + DIOLAN_USB_TIMEOUT); 125 + /* 126 + * Stop command processing if a previous command 127 + * returned an error. 128 + * Note that we still need to retrieve all messages. 129 + */ 130 + if (ret < 0) 131 + continue; 132 + ret = tmpret; 133 + if (ret == 0 && actual > 0) { 134 + switch (dev->ibuffer[actual - 1]) { 135 + case RESP_NACK: 136 + /* 137 + * Return ENXIO if NACK was received as 138 + * response to the address phase, 139 + * EIO otherwise 140 + */ 141 + ret = i == 1 ? -ENXIO : -EIO; 142 + break; 143 + case RESP_TIMEOUT: 144 + ret = -ETIMEDOUT; 145 + break; 146 + case RESP_OK: 147 + /* strip off return code */ 148 + ret = actual - 1; 149 + break; 150 + default: 151 + ret = -EIO; 152 + break; 153 + } 154 + } 155 + } 156 + } 157 + dev->olen = 0; 158 + dev->ocount = 0; 159 + return ret; 160 + } 161 + 162 + static int diolan_write_cmd(struct i2c_diolan_u2c *dev, bool flush) 163 + { 164 + if (flush || dev->olen >= DIOLAN_FLUSH_LEN) 165 + return diolan_usb_transfer(dev); 166 + return 0; 167 + } 168 + 169 + /* Send command (no data) */ 170 + static int diolan_usb_cmd(struct i2c_diolan_u2c *dev, u8 command, bool flush) 171 + { 172 + dev->obuffer[dev->olen++] = command; 173 + dev->ocount++; 174 + return diolan_write_cmd(dev, flush); 175 + } 176 + 177 + /* Send command with one byte of data */ 178 + static int diolan_usb_cmd_data(struct i2c_diolan_u2c *dev, u8 command, u8 data, 179 + bool flush) 180 + { 181 + dev->obuffer[dev->olen++] = command; 182 + dev->obuffer[dev->olen++] = data; 183 + dev->ocount++; 184 + return diolan_write_cmd(dev, flush); 185 + } 186 + 187 + /* Send command with two bytes of data */ 188 + static int diolan_usb_cmd_data2(struct i2c_diolan_u2c *dev, u8 command, u8 d1, 189 + u8 d2, bool flush) 190 + { 191 + dev->obuffer[dev->olen++] = command; 192 + dev->obuffer[dev->olen++] = d1; 193 + dev->obuffer[dev->olen++] = d2; 194 + dev->ocount++; 195 + return diolan_write_cmd(dev, flush); 196 + } 197 + 198 + /* 199 + * Flush input queue. 200 + * If we don't do this at startup and the controller has queued up 201 + * messages which were not retrieved, it will stop responding 202 + * at some point. 203 + */ 204 + static void diolan_flush_input(struct i2c_diolan_u2c *dev) 205 + { 206 + int i; 207 + 208 + for (i = 0; i < 10; i++) { 209 + int actual = 0; 210 + int ret; 211 + 212 + ret = usb_bulk_msg(dev->usb_dev, 213 + usb_rcvbulkpipe(dev->usb_dev, DIOLAN_IN_EP), 214 + dev->ibuffer, sizeof(dev->ibuffer), &actual, 215 + DIOLAN_USB_TIMEOUT); 216 + if (ret < 0 || actual == 0) 217 + break; 218 + } 219 + if (i == 10) 220 + dev_err(&dev->interface->dev, "Failed to flush input buffer\n"); 221 + } 222 + 223 + static int diolan_i2c_start(struct i2c_diolan_u2c *dev) 224 + { 225 + return diolan_usb_cmd(dev, CMD_I2C_START, false); 226 + } 227 + 228 + static int diolan_i2c_repeated_start(struct i2c_diolan_u2c *dev) 229 + { 230 + return diolan_usb_cmd(dev, CMD_I2C_REPEATED_START, false); 231 + } 232 + 233 + static int diolan_i2c_stop(struct i2c_diolan_u2c *dev) 234 + { 235 + return diolan_usb_cmd(dev, CMD_I2C_STOP, true); 236 + } 237 + 238 + static int diolan_i2c_get_byte_ack(struct i2c_diolan_u2c *dev, bool ack, 239 + u8 *byte) 240 + { 241 + int ret; 242 + 243 + ret = diolan_usb_cmd_data(dev, CMD_I2C_GET_BYTE_ACK, ack, true); 244 + if (ret > 0) 245 + *byte = dev->ibuffer[0]; 246 + else if (ret == 0) 247 + ret = -EIO; 248 + 249 + return ret; 250 + } 251 + 252 + static int diolan_i2c_put_byte_ack(struct i2c_diolan_u2c *dev, u8 byte) 253 + { 254 + return diolan_usb_cmd_data(dev, CMD_I2C_PUT_BYTE_ACK, byte, false); 255 + } 256 + 257 + static int diolan_set_speed(struct i2c_diolan_u2c *dev, u8 speed) 258 + { 259 + return diolan_usb_cmd_data(dev, CMD_I2C_SET_SPEED, speed, true); 260 + } 261 + 262 + /* Enable or disable clock synchronization (stretching) */ 263 + static int diolan_set_clock_synch(struct i2c_diolan_u2c *dev, bool enable) 264 + { 265 + return diolan_usb_cmd_data(dev, CMD_I2C_SET_CLK_SYNC, enable, true); 266 + } 267 + 268 + /* Set clock synchronization timeout in ms */ 269 + static int diolan_set_clock_synch_timeout(struct i2c_diolan_u2c *dev, int ms) 270 + { 271 + int to_val = ms * 10; 272 + 273 + return diolan_usb_cmd_data2(dev, CMD_I2C_SET_CLK_SYNC_TO, 274 + to_val & 0xff, (to_val >> 8) & 0xff, true); 275 + } 276 + 277 + static void diolan_fw_version(struct i2c_diolan_u2c *dev) 278 + { 279 + int ret; 280 + 281 + ret = diolan_usb_cmd(dev, CMD_GET_FW_VERSION, true); 282 + if (ret >= 2) 283 + dev_info(&dev->interface->dev, 284 + "Diolan U2C firmware version %u.%u\n", 285 + (unsigned int)dev->ibuffer[0], 286 + (unsigned int)dev->ibuffer[1]); 287 + } 288 + 289 + static void diolan_get_serial(struct i2c_diolan_u2c *dev) 290 + { 291 + int ret; 292 + u32 serial; 293 + 294 + ret = diolan_usb_cmd(dev, CMD_GET_SERIAL, true); 295 + if (ret >= 4) { 296 + serial = le32_to_cpu(*(u32 *)dev->ibuffer); 297 + dev_info(&dev->interface->dev, 298 + "Diolan U2C serial number %u\n", serial); 299 + } 300 + } 301 + 302 + static int diolan_init(struct i2c_diolan_u2c *dev) 303 + { 304 + int speed, ret; 305 + 306 + if (frequency >= 200000) { 307 + speed = U2C_I2C_SPEED_FAST; 308 + frequency = U2C_I2C_FREQ_FAST; 309 + } else if (frequency >= 100000 || frequency == 0) { 310 + speed = U2C_I2C_SPEED_STD; 311 + frequency = U2C_I2C_FREQ_STD; 312 + } else { 313 + speed = U2C_I2C_SPEED(frequency); 314 + if (speed > U2C_I2C_SPEED_2KHZ) 315 + speed = U2C_I2C_SPEED_2KHZ; 316 + frequency = U2C_I2C_FREQ(speed); 317 + } 318 + 319 + dev_info(&dev->interface->dev, 320 + "Diolan U2C at USB bus %03d address %03d speed %d Hz\n", 321 + dev->usb_dev->bus->busnum, dev->usb_dev->devnum, frequency); 322 + 323 + diolan_flush_input(dev); 324 + diolan_fw_version(dev); 325 + diolan_get_serial(dev); 326 + 327 + /* Set I2C speed */ 328 + ret = diolan_set_speed(dev, speed); 329 + if (ret < 0) 330 + return ret; 331 + 332 + /* Configure I2C clock synchronization */ 333 + ret = diolan_set_clock_synch(dev, speed != U2C_I2C_SPEED_FAST); 334 + if (ret < 0) 335 + return ret; 336 + 337 + if (speed != U2C_I2C_SPEED_FAST) 338 + ret = diolan_set_clock_synch_timeout(dev, DIOLAN_SYNC_TIMEOUT); 339 + 340 + return ret; 341 + } 342 + 343 + /* i2c layer */ 344 + 345 + static int diolan_usb_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, 346 + int num) 347 + { 348 + struct i2c_diolan_u2c *dev = i2c_get_adapdata(adapter); 349 + struct i2c_msg *pmsg; 350 + int i, j; 351 + int ret, sret; 352 + 353 + ret = diolan_i2c_start(dev); 354 + if (ret < 0) 355 + return ret; 356 + 357 + for (i = 0; i < num; i++) { 358 + pmsg = &msgs[i]; 359 + if (i) { 360 + ret = diolan_i2c_repeated_start(dev); 361 + if (ret < 0) 362 + goto abort; 363 + } 364 + if (pmsg->flags & I2C_M_RD) { 365 + ret = 366 + diolan_i2c_put_byte_ack(dev, (pmsg->addr << 1) | 1); 367 + if (ret < 0) 368 + goto abort; 369 + for (j = 0; j < pmsg->len; j++) { 370 + u8 byte; 371 + bool ack = j < pmsg->len - 1; 372 + 373 + /* 374 + * Don't send NACK if this is the first byte 375 + * of a SMBUS_BLOCK message. 376 + */ 377 + if (j == 0 && (pmsg->flags & I2C_M_RECV_LEN)) 378 + ack = true; 379 + 380 + ret = diolan_i2c_get_byte_ack(dev, ack, &byte); 381 + if (ret < 0) 382 + goto abort; 383 + /* 384 + * Adjust count if first received byte is length 385 + */ 386 + if (j == 0 && (pmsg->flags & I2C_M_RECV_LEN)) { 387 + if (byte == 0 388 + || byte > I2C_SMBUS_BLOCK_MAX) { 389 + ret = -EPROTO; 390 + goto abort; 391 + } 392 + pmsg->len += byte; 393 + } 394 + pmsg->buf[j] = byte; 395 + } 396 + } else { 397 + ret = diolan_i2c_put_byte_ack(dev, pmsg->addr << 1); 398 + if (ret < 0) 399 + goto abort; 400 + for (j = 0; j < pmsg->len; j++) { 401 + ret = diolan_i2c_put_byte_ack(dev, 402 + pmsg->buf[j]); 403 + if (ret < 0) 404 + goto abort; 405 + } 406 + } 407 + } 408 + abort: 409 + sret = diolan_i2c_stop(dev); 410 + if (sret < 0 && ret >= 0) 411 + ret = sret; 412 + return ret; 413 + } 414 + 415 + /* 416 + * Return list of supported functionality. 417 + */ 418 + static u32 diolan_usb_func(struct i2c_adapter *a) 419 + { 420 + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | 421 + I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_FUNC_SMBUS_BLOCK_PROC_CALL; 422 + } 423 + 424 + static const struct i2c_algorithm diolan_usb_algorithm = { 425 + .master_xfer = diolan_usb_xfer, 426 + .functionality = diolan_usb_func, 427 + }; 428 + 429 + /* device layer */ 430 + 431 + static const struct usb_device_id diolan_u2c_table[] = { 432 + { USB_DEVICE(USB_VENDOR_ID_DIOLAN, USB_DEVICE_ID_DIOLAN_U2C) }, 433 + { } 434 + }; 435 + 436 + MODULE_DEVICE_TABLE(usb, diolan_u2c_table); 437 + 438 + static void diolan_u2c_free(struct i2c_diolan_u2c *dev) 439 + { 440 + usb_put_dev(dev->usb_dev); 441 + kfree(dev); 442 + } 443 + 444 + static int diolan_u2c_probe(struct usb_interface *interface, 445 + const struct usb_device_id *id) 446 + { 447 + struct i2c_diolan_u2c *dev; 448 + int ret; 449 + 450 + /* allocate memory for our device state and initialize it */ 451 + dev = kzalloc(sizeof(*dev), GFP_KERNEL); 452 + if (dev == NULL) { 453 + dev_err(&interface->dev, "no memory for device state\n"); 454 + ret = -ENOMEM; 455 + goto error; 456 + } 457 + 458 + dev->usb_dev = usb_get_dev(interface_to_usbdev(interface)); 459 + dev->interface = interface; 460 + 461 + /* save our data pointer in this interface device */ 462 + usb_set_intfdata(interface, dev); 463 + 464 + /* setup i2c adapter description */ 465 + dev->adapter.owner = THIS_MODULE; 466 + dev->adapter.class = I2C_CLASS_HWMON; 467 + dev->adapter.algo = &diolan_usb_algorithm; 468 + i2c_set_adapdata(&dev->adapter, dev); 469 + snprintf(dev->adapter.name, sizeof(dev->adapter.name), 470 + DRIVER_NAME " at bus %03d device %03d", 471 + dev->usb_dev->bus->busnum, dev->usb_dev->devnum); 472 + 473 + dev->adapter.dev.parent = &dev->interface->dev; 474 + 475 + /* initialize diolan i2c interface */ 476 + ret = diolan_init(dev); 477 + if (ret < 0) { 478 + dev_err(&interface->dev, "failed to initialize adapter\n"); 479 + goto error_free; 480 + } 481 + 482 + /* and finally attach to i2c layer */ 483 + ret = i2c_add_adapter(&dev->adapter); 484 + if (ret < 0) { 485 + dev_err(&interface->dev, "failed to add I2C adapter\n"); 486 + goto error_free; 487 + } 488 + 489 + dev_dbg(&interface->dev, "connected " DRIVER_NAME "\n"); 490 + 491 + return 0; 492 + 493 + error_free: 494 + usb_set_intfdata(interface, NULL); 495 + diolan_u2c_free(dev); 496 + error: 497 + return ret; 498 + } 499 + 500 + static void diolan_u2c_disconnect(struct usb_interface *interface) 501 + { 502 + struct i2c_diolan_u2c *dev = usb_get_intfdata(interface); 503 + 504 + i2c_del_adapter(&dev->adapter); 505 + usb_set_intfdata(interface, NULL); 506 + diolan_u2c_free(dev); 507 + 508 + dev_dbg(&interface->dev, "disconnected\n"); 509 + } 510 + 511 + static struct usb_driver diolan_u2c_driver = { 512 + .name = DRIVER_NAME, 513 + .probe = diolan_u2c_probe, 514 + .disconnect = diolan_u2c_disconnect, 515 + .id_table = diolan_u2c_table, 516 + }; 517 + 518 + static int __init diolan_u2c_init(void) 519 + { 520 + /* register this driver with the USB subsystem */ 521 + return usb_register(&diolan_u2c_driver); 522 + } 523 + 524 + static void __exit diolan_u2c_exit(void) 525 + { 526 + /* deregister this driver with the USB subsystem */ 527 + usb_deregister(&diolan_u2c_driver); 528 + } 529 + 530 + module_init(diolan_u2c_init); 531 + module_exit(diolan_u2c_exit); 532 + 533 + MODULE_AUTHOR("Guenter Roeck <guenter.roeck@ericsson.com>"); 534 + MODULE_DESCRIPTION(DRIVER_NAME " driver"); 535 + MODULE_LICENSE("GPL");
+98 -61
drivers/i2c/busses/i2c-eg20t.c
··· 132 132 #define pch_pci_dbg(pdev, fmt, arg...) \ 133 133 dev_dbg(&pdev->dev, "%s :" fmt, __func__, ##arg) 134 134 135 + /* 136 + Set the number of I2C instance max 137 + Intel EG20T PCH : 1ch 138 + OKI SEMICONDUCTOR ML7213 IOH : 2ch 139 + */ 140 + #define PCH_I2C_MAX_DEV 2 141 + 135 142 /** 136 143 * struct i2c_algo_pch_data - for I2C driver functionalities 137 144 * @pch_adapter: stores the reference to i2c_adapter structure ··· 163 156 * @pch_data: stores a list of i2c_algo_pch_data 164 157 * @pch_i2c_suspended: specifies whether the system is suspended or not 165 158 * perhaps with more lines and words. 159 + * @ch_num: specifies the number of i2c instance 166 160 * 167 161 * pch_data has as many elements as maximum I2C channels 168 162 */ 169 163 struct adapter_info { 170 - struct i2c_algo_pch_data pch_data; 164 + struct i2c_algo_pch_data pch_data[PCH_I2C_MAX_DEV]; 171 165 bool pch_i2c_suspended; 166 + int ch_num; 172 167 }; 173 168 174 169 ··· 179 170 static wait_queue_head_t pch_event; 180 171 static DEFINE_MUTEX(pch_mutex); 181 172 173 + /* Definition for ML7213 by OKI SEMICONDUCTOR */ 174 + #define PCI_VENDOR_ID_ROHM 0x10DB 175 + #define PCI_DEVICE_ID_ML7213_I2C 0x802D 176 + 182 177 static struct pci_device_id __devinitdata pch_pcidev_id[] = { 183 - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PCH_I2C)}, 178 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PCH_I2C), 1, }, 179 + { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7213_I2C), 2, }, 184 180 {0,} 185 181 }; 186 182 ··· 226 212 /* Initialize I2C registers */ 227 213 iowrite32(0x21, p + PCH_I2CNF); 228 214 229 - pch_setbit(adap->pch_base_address, PCH_I2CCTL, 230 - PCH_I2CCTL_I2CMEN); 215 + pch_setbit(adap->pch_base_address, PCH_I2CCTL, PCH_I2CCTL_I2CMEN); 231 216 232 217 if (pch_i2c_speed != 400) 233 218 pch_i2c_speed = 100; ··· 268 255 * @timeout: waiting time counter (us). 269 256 */ 270 257 static s32 pch_i2c_wait_for_bus_idle(struct i2c_algo_pch_data *adap, 271 - s32 timeout) 258 + s32 timeout) 272 259 { 273 260 void __iomem *p = adap->pch_base_address; 274 261 ··· 488 475 * @last: specifies whether last message or not. 489 476 * @first: specifies whether first message or not. 490 477 */ 491 - s32 pch_i2c_readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, 492 - u32 last, u32 first) 478 + static s32 pch_i2c_readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, 479 + u32 last, u32 first) 493 480 { 494 481 struct i2c_algo_pch_data *adap = i2c_adap->algo_data; 495 482 ··· 582 569 } 583 570 584 571 /** 585 - * pch_i2c_cb_ch0() - Interrupt handler Call back function 572 + * pch_i2c_cb() - Interrupt handler Call back function 586 573 * @adap: Pointer to struct i2c_algo_pch_data. 587 574 */ 588 - static void pch_i2c_cb_ch0(struct i2c_algo_pch_data *adap) 575 + static void pch_i2c_cb(struct i2c_algo_pch_data *adap) 589 576 { 590 577 u32 sts; 591 578 void __iomem *p = adap->pch_base_address; ··· 613 600 */ 614 601 static irqreturn_t pch_i2c_handler(int irq, void *pData) 615 602 { 616 - s32 reg_val; 603 + u32 reg_val; 604 + int flag; 605 + int i; 606 + struct adapter_info *adap_info = pData; 607 + void __iomem *p; 608 + u32 mode; 617 609 618 - struct i2c_algo_pch_data *adap_data = (struct i2c_algo_pch_data *)pData; 619 - void __iomem *p = adap_data->pch_base_address; 620 - u32 mode = ioread32(p + PCH_I2CMOD) & (BUFFER_MODE | EEPROM_SR_MODE); 621 - 622 - if (mode != NORMAL_MODE) { 623 - pch_err(adap_data, "I2C mode is not supported\n"); 624 - return IRQ_NONE; 610 + for (i = 0, flag = 0; i < adap_info->ch_num; i++) { 611 + p = adap_info->pch_data[i].pch_base_address; 612 + mode = ioread32(p + PCH_I2CMOD); 613 + mode &= BUFFER_MODE | EEPROM_SR_MODE; 614 + if (mode != NORMAL_MODE) { 615 + pch_err(adap_info->pch_data, 616 + "I2C-%d mode(%d) is not supported\n", mode, i); 617 + continue; 618 + } 619 + reg_val = ioread32(p + PCH_I2CSR); 620 + if (reg_val & (I2CMAL_BIT | I2CMCF_BIT | I2CMIF_BIT)) { 621 + pch_i2c_cb(&adap_info->pch_data[i]); 622 + flag = 1; 623 + } 625 624 } 626 625 627 - reg_val = ioread32(p + PCH_I2CSR); 628 - if (reg_val & (I2CMAL_BIT | I2CMCF_BIT | I2CMIF_BIT)) 629 - pch_i2c_cb_ch0(adap_data); 630 - else 631 - return IRQ_NONE; 632 - 633 - return IRQ_HANDLED; 626 + return flag ? IRQ_HANDLED : IRQ_NONE; 634 627 } 635 628 636 629 /** ··· 646 627 * @num: number of messages. 647 628 */ 648 629 static s32 pch_i2c_xfer(struct i2c_adapter *i2c_adap, 649 - struct i2c_msg *msgs, s32 num) 630 + struct i2c_msg *msgs, s32 num) 650 631 { 651 632 struct i2c_msg *pmsg; 652 633 u32 i = 0; ··· 729 710 } 730 711 731 712 static int __devinit pch_i2c_probe(struct pci_dev *pdev, 732 - const struct pci_device_id *id) 713 + const struct pci_device_id *id) 733 714 { 734 715 void __iomem *base_addr; 735 - s32 ret; 716 + int ret; 717 + int i, j; 736 718 struct adapter_info *adap_info; 719 + struct i2c_adapter *pch_adap; 737 720 738 721 pch_pci_dbg(pdev, "Entered.\n"); 739 722 ··· 765 744 goto err_pci_iomap; 766 745 } 767 746 768 - adap_info->pch_i2c_suspended = false; 747 + /* Set the number of I2C channel instance */ 748 + adap_info->ch_num = id->driver_data; 769 749 770 - adap_info->pch_data.p_adapter_info = adap_info; 750 + for (i = 0; i < adap_info->ch_num; i++) { 751 + pch_adap = &adap_info->pch_data[i].pch_adapter; 752 + adap_info->pch_i2c_suspended = false; 771 753 772 - adap_info->pch_data.pch_adapter.owner = THIS_MODULE; 773 - adap_info->pch_data.pch_adapter.class = I2C_CLASS_HWMON; 774 - strcpy(adap_info->pch_data.pch_adapter.name, KBUILD_MODNAME); 775 - adap_info->pch_data.pch_adapter.algo = &pch_algorithm; 776 - adap_info->pch_data.pch_adapter.algo_data = 777 - &adap_info->pch_data; 754 + adap_info->pch_data[i].p_adapter_info = adap_info; 778 755 779 - /* (i * 0x80) + base_addr; */ 780 - adap_info->pch_data.pch_base_address = base_addr; 756 + pch_adap->owner = THIS_MODULE; 757 + pch_adap->class = I2C_CLASS_HWMON; 758 + strcpy(pch_adap->name, KBUILD_MODNAME); 759 + pch_adap->algo = &pch_algorithm; 760 + pch_adap->algo_data = &adap_info->pch_data[i]; 781 761 782 - adap_info->pch_data.pch_adapter.dev.parent = &pdev->dev; 762 + /* base_addr + offset; */ 763 + adap_info->pch_data[i].pch_base_address = base_addr + 0x100 * i; 783 764 784 - ret = i2c_add_adapter(&(adap_info->pch_data.pch_adapter)); 765 + pch_adap->dev.parent = &pdev->dev; 785 766 786 - if (ret) { 787 - pch_pci_err(pdev, "i2c_add_adapter FAILED\n"); 788 - goto err_i2c_add_adapter; 767 + ret = i2c_add_adapter(pch_adap); 768 + if (ret) { 769 + pch_pci_err(pdev, "i2c_add_adapter[ch:%d] FAILED\n", i); 770 + goto err_i2c_add_adapter; 771 + } 772 + 773 + pch_i2c_init(&adap_info->pch_data[i]); 789 774 } 790 - 791 - pch_i2c_init(&adap_info->pch_data); 792 775 ret = request_irq(pdev->irq, pch_i2c_handler, IRQF_SHARED, 793 - KBUILD_MODNAME, &adap_info->pch_data); 776 + KBUILD_MODNAME, adap_info); 794 777 if (ret) { 795 778 pch_pci_err(pdev, "request_irq FAILED\n"); 796 - goto err_request_irq; 779 + goto err_i2c_add_adapter; 797 780 } 798 781 799 782 pci_set_drvdata(pdev, adap_info); 800 783 pch_pci_dbg(pdev, "returns %d.\n", ret); 801 784 return 0; 802 785 803 - err_request_irq: 804 - i2c_del_adapter(&(adap_info->pch_data.pch_adapter)); 805 786 err_i2c_add_adapter: 787 + for (j = 0; j < i; j++) 788 + i2c_del_adapter(&adap_info->pch_data[j].pch_adapter); 806 789 pci_iounmap(pdev, base_addr); 807 790 err_pci_iomap: 808 791 pci_release_regions(pdev); ··· 819 794 820 795 static void __devexit pch_i2c_remove(struct pci_dev *pdev) 821 796 { 797 + int i; 822 798 struct adapter_info *adap_info = pci_get_drvdata(pdev); 823 799 824 - pch_i2c_disbl_int(&adap_info->pch_data); 825 - free_irq(pdev->irq, &adap_info->pch_data); 826 - i2c_del_adapter(&(adap_info->pch_data.pch_adapter)); 800 + free_irq(pdev->irq, adap_info); 827 801 828 - if (adap_info->pch_data.pch_base_address) { 829 - pci_iounmap(pdev, adap_info->pch_data.pch_base_address); 830 - adap_info->pch_data.pch_base_address = 0; 802 + for (i = 0; i < adap_info->ch_num; i++) { 803 + pch_i2c_disbl_int(&adap_info->pch_data[i]); 804 + i2c_del_adapter(&adap_info->pch_data[i].pch_adapter); 831 805 } 806 + 807 + if (adap_info->pch_data[0].pch_base_address) 808 + pci_iounmap(pdev, adap_info->pch_data[0].pch_base_address); 809 + 810 + for (i = 0; i < adap_info->ch_num; i++) 811 + adap_info->pch_data[i].pch_base_address = 0; 832 812 833 813 pci_set_drvdata(pdev, NULL); 834 814 ··· 847 817 static int pch_i2c_suspend(struct pci_dev *pdev, pm_message_t state) 848 818 { 849 819 int ret; 820 + int i; 850 821 struct adapter_info *adap_info = pci_get_drvdata(pdev); 851 - void __iomem *p = adap_info->pch_data.pch_base_address; 822 + void __iomem *p = adap_info->pch_data[0].pch_base_address; 852 823 853 824 adap_info->pch_i2c_suspended = true; 854 825 855 - while ((adap_info->pch_data.pch_i2c_xfer_in_progress)) { 856 - /* Wait until all channel transfers are completed */ 857 - msleep(20); 826 + for (i = 0; i < adap_info->ch_num; i++) { 827 + while ((adap_info->pch_data[i].pch_i2c_xfer_in_progress)) { 828 + /* Wait until all channel transfers are completed */ 829 + msleep(20); 830 + } 858 831 } 832 + 859 833 /* Disable the i2c interrupts */ 860 - pch_i2c_disbl_int(&adap_info->pch_data); 834 + for (i = 0; i < adap_info->ch_num; i++) 835 + pch_i2c_disbl_int(&adap_info->pch_data[i]); 861 836 862 837 pch_pci_dbg(pdev, "I2CSR = %x I2CBUFSTA = %x I2CESRSTA = %x " 863 838 "invoked function pch_i2c_disbl_int successfully\n", ··· 885 850 886 851 static int pch_i2c_resume(struct pci_dev *pdev) 887 852 { 853 + int i; 888 854 struct adapter_info *adap_info = pci_get_drvdata(pdev); 889 855 890 856 pci_set_power_state(pdev, PCI_D0); ··· 898 862 899 863 pci_enable_wake(pdev, PCI_D3hot, 0); 900 864 901 - pch_i2c_init(&adap_info->pch_data); 865 + for (i = 0; i < adap_info->ch_num; i++) 866 + pch_i2c_init(&adap_info->pch_data[i]); 902 867 903 868 adap_info->pch_i2c_suspended = false; 904 869 ··· 931 894 } 932 895 module_exit(pch_pci_exit); 933 896 934 - MODULE_DESCRIPTION("PCH I2C PCI Driver"); 897 + MODULE_DESCRIPTION("Intel EG20T PCH/OKI SEMICONDUCTOR ML7213 IOH I2C Driver"); 935 898 MODULE_LICENSE("GPL"); 936 899 MODULE_AUTHOR("Tomoya MORINAGA. <tomoya-linux@dsn.okisemi.com>"); 937 900 module_param(pch_i2c_speed, int, (S_IRUSR | S_IWUSR));
+2 -2
drivers/i2c/busses/i2c-mxs.c
··· 118 118 { 119 119 mxs_reset_block(i2c->regs); 120 120 writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET); 121 + writel(MXS_I2C_QUEUECTRL_PIO_QUEUE_MODE, 122 + i2c->regs + MXS_I2C_QUEUECTRL_SET); 121 123 } 122 124 123 125 static void mxs_i2c_pioq_setup_read(struct mxs_i2c_dev *i2c, u8 addr, int len, ··· 349 347 350 348 /* Do reset to enforce correct startup after pinmuxing */ 351 349 mxs_i2c_reset(i2c); 352 - writel(MXS_I2C_QUEUECTRL_PIO_QUEUE_MODE, 353 - i2c->regs + MXS_I2C_QUEUECTRL_SET); 354 350 355 351 adap = &i2c->adapter; 356 352 strlcpy(adap->name, "MXS I2C adapter", sizeof(adap->name));
+176
drivers/i2c/busses/i2c-pxa-pci.c
··· 1 + /* 2 + * The CE4100's I2C device is more or less the same one as found on PXA. 3 + * It does not support slave mode, the register slightly moved. This PCI 4 + * device provides three bars, every contains a single I2C controller. 5 + */ 6 + #include <linux/pci.h> 7 + #include <linux/platform_device.h> 8 + #include <linux/i2c/pxa-i2c.h> 9 + #include <linux/of.h> 10 + #include <linux/of_device.h> 11 + #include <linux/of_address.h> 12 + 13 + #define CE4100_PCI_I2C_DEVS 3 14 + 15 + struct ce4100_devices { 16 + struct platform_device *pdev[CE4100_PCI_I2C_DEVS]; 17 + }; 18 + 19 + static struct platform_device *add_i2c_device(struct pci_dev *dev, int bar) 20 + { 21 + struct platform_device *pdev; 22 + struct i2c_pxa_platform_data pdata; 23 + struct resource res[2]; 24 + struct device_node *child; 25 + static int devnum; 26 + int ret; 27 + 28 + memset(&pdata, 0, sizeof(struct i2c_pxa_platform_data)); 29 + memset(&res, 0, sizeof(res)); 30 + 31 + res[0].flags = IORESOURCE_MEM; 32 + res[0].start = pci_resource_start(dev, bar); 33 + res[0].end = pci_resource_end(dev, bar); 34 + 35 + res[1].flags = IORESOURCE_IRQ; 36 + res[1].start = dev->irq; 37 + res[1].end = dev->irq; 38 + 39 + for_each_child_of_node(dev->dev.of_node, child) { 40 + const void *prop; 41 + struct resource r; 42 + int ret; 43 + 44 + ret = of_address_to_resource(child, 0, &r); 45 + if (ret < 0) 46 + continue; 47 + if (r.start != res[0].start) 48 + continue; 49 + if (r.end != res[0].end) 50 + continue; 51 + if (r.flags != res[0].flags) 52 + continue; 53 + 54 + prop = of_get_property(child, "fast-mode", NULL); 55 + if (prop) 56 + pdata.fast_mode = 1; 57 + 58 + break; 59 + } 60 + 61 + if (!child) { 62 + dev_err(&dev->dev, "failed to match a DT node for bar %d.\n", 63 + bar); 64 + ret = -EINVAL; 65 + goto out; 66 + } 67 + 68 + pdev = platform_device_alloc("ce4100-i2c", devnum); 69 + if (!pdev) { 70 + of_node_put(child); 71 + ret = -ENOMEM; 72 + goto out; 73 + } 74 + pdev->dev.parent = &dev->dev; 75 + pdev->dev.of_node = child; 76 + 77 + ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res)); 78 + if (ret) 79 + goto err; 80 + 81 + ret = platform_device_add_data(pdev, &pdata, sizeof(pdata)); 82 + if (ret) 83 + goto err; 84 + 85 + ret = platform_device_add(pdev); 86 + if (ret) 87 + goto err; 88 + devnum++; 89 + return pdev; 90 + err: 91 + platform_device_put(pdev); 92 + out: 93 + return ERR_PTR(ret); 94 + } 95 + 96 + static int __devinit ce4100_i2c_probe(struct pci_dev *dev, 97 + const struct pci_device_id *ent) 98 + { 99 + int ret; 100 + int i; 101 + struct ce4100_devices *sds; 102 + 103 + ret = pci_enable_device_mem(dev); 104 + if (ret) 105 + return ret; 106 + 107 + if (!dev->dev.of_node) { 108 + dev_err(&dev->dev, "Missing device tree node.\n"); 109 + return -EINVAL; 110 + } 111 + sds = kzalloc(sizeof(*sds), GFP_KERNEL); 112 + if (!sds) 113 + goto err_mem; 114 + 115 + for (i = 0; i < ARRAY_SIZE(sds->pdev); i++) { 116 + sds->pdev[i] = add_i2c_device(dev, i); 117 + if (IS_ERR(sds->pdev[i])) { 118 + while (--i >= 0) 119 + platform_device_unregister(sds->pdev[i]); 120 + goto err_dev_add; 121 + } 122 + } 123 + pci_set_drvdata(dev, sds); 124 + return 0; 125 + 126 + err_dev_add: 127 + pci_set_drvdata(dev, NULL); 128 + kfree(sds); 129 + err_mem: 130 + pci_disable_device(dev); 131 + return ret; 132 + } 133 + 134 + static void __devexit ce4100_i2c_remove(struct pci_dev *dev) 135 + { 136 + struct ce4100_devices *sds; 137 + unsigned int i; 138 + 139 + sds = pci_get_drvdata(dev); 140 + pci_set_drvdata(dev, NULL); 141 + 142 + for (i = 0; i < ARRAY_SIZE(sds->pdev); i++) 143 + platform_device_unregister(sds->pdev[i]); 144 + 145 + pci_disable_device(dev); 146 + kfree(sds); 147 + } 148 + 149 + static struct pci_device_id ce4100_i2c_devices[] __devinitdata = { 150 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e68)}, 151 + { }, 152 + }; 153 + MODULE_DEVICE_TABLE(pci, ce4100_i2c_devices); 154 + 155 + static struct pci_driver ce4100_i2c_driver = { 156 + .name = "ce4100_i2c", 157 + .id_table = ce4100_i2c_devices, 158 + .probe = ce4100_i2c_probe, 159 + .remove = __devexit_p(ce4100_i2c_remove), 160 + }; 161 + 162 + static int __init ce4100_i2c_init(void) 163 + { 164 + return pci_register_driver(&ce4100_i2c_driver); 165 + } 166 + module_init(ce4100_i2c_init); 167 + 168 + static void __exit ce4100_i2c_exit(void) 169 + { 170 + pci_unregister_driver(&ce4100_i2c_driver); 171 + } 172 + module_exit(ce4100_i2c_exit); 173 + 174 + MODULE_DESCRIPTION("CE4100 PCI-I2C glue code for PXA's driver"); 175 + MODULE_LICENSE("GPL v2"); 176 + MODULE_AUTHOR("Sebastian Andrzej Siewior <bigeasy@linutronix.de>");
+89 -26
drivers/i2c/busses/i2c-pxa.c
··· 29 29 #include <linux/errno.h> 30 30 #include <linux/interrupt.h> 31 31 #include <linux/i2c-pxa.h> 32 + #include <linux/of_i2c.h> 32 33 #include <linux/platform_device.h> 33 34 #include <linux/err.h> 34 35 #include <linux/clk.h> 35 36 #include <linux/slab.h> 36 37 #include <linux/io.h> 38 + #include <linux/i2c/pxa-i2c.h> 37 39 38 40 #include <asm/irq.h> 39 - #include <plat/i2c.h> 41 + 42 + #ifndef CONFIG_HAVE_CLK 43 + #define clk_get(dev, id) NULL 44 + #define clk_put(clk) do { } while (0) 45 + #define clk_disable(clk) do { } while (0) 46 + #define clk_enable(clk) do { } while (0) 47 + #endif 48 + 49 + struct pxa_reg_layout { 50 + u32 ibmr; 51 + u32 idbr; 52 + u32 icr; 53 + u32 isr; 54 + u32 isar; 55 + }; 56 + 57 + enum pxa_i2c_types { 58 + REGS_PXA2XX, 59 + REGS_PXA3XX, 60 + REGS_CE4100, 61 + }; 40 62 41 63 /* 42 - * I2C register offsets will be shifted 0 or 1 bit left, depending on 43 - * different SoCs 64 + * I2C registers definitions 44 65 */ 45 - #define REG_SHIFT_0 (0 << 0) 46 - #define REG_SHIFT_1 (1 << 0) 47 - #define REG_SHIFT(d) ((d) & 0x1) 66 + static struct pxa_reg_layout pxa_reg_layout[] = { 67 + [REGS_PXA2XX] = { 68 + .ibmr = 0x00, 69 + .idbr = 0x08, 70 + .icr = 0x10, 71 + .isr = 0x18, 72 + .isar = 0x20, 73 + }, 74 + [REGS_PXA3XX] = { 75 + .ibmr = 0x00, 76 + .idbr = 0x04, 77 + .icr = 0x08, 78 + .isr = 0x0c, 79 + .isar = 0x10, 80 + }, 81 + [REGS_CE4100] = { 82 + .ibmr = 0x14, 83 + .idbr = 0x0c, 84 + .icr = 0x00, 85 + .isr = 0x04, 86 + /* no isar register */ 87 + }, 88 + }; 48 89 49 90 static const struct platform_device_id i2c_pxa_id_table[] = { 50 - { "pxa2xx-i2c", REG_SHIFT_1 }, 51 - { "pxa3xx-pwri2c", REG_SHIFT_0 }, 91 + { "pxa2xx-i2c", REGS_PXA2XX }, 92 + { "pxa3xx-pwri2c", REGS_PXA3XX }, 93 + { "ce4100-i2c", REGS_CE4100 }, 52 94 { }, 53 95 }; 54 96 MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table); 55 97 56 98 /* 57 - * I2C registers and bit definitions 99 + * I2C bit definitions 58 100 */ 59 - #define IBMR (0x00) 60 - #define IDBR (0x08) 61 - #define ICR (0x10) 62 - #define ISR (0x18) 63 - #define ISAR (0x20) 64 101 65 102 #define ICR_START (1 << 0) /* start bit */ 66 103 #define ICR_STOP (1 << 1) /* stop bit */ ··· 148 111 u32 icrlog[32]; 149 112 150 113 void __iomem *reg_base; 151 - unsigned int reg_shift; 114 + void __iomem *reg_ibmr; 115 + void __iomem *reg_idbr; 116 + void __iomem *reg_icr; 117 + void __iomem *reg_isr; 118 + void __iomem *reg_isar; 152 119 153 120 unsigned long iobase; 154 121 unsigned long iosize; ··· 162 121 unsigned int fast_mode :1; 163 122 }; 164 123 165 - #define _IBMR(i2c) ((i2c)->reg_base + (0x0 << (i2c)->reg_shift)) 166 - #define _IDBR(i2c) ((i2c)->reg_base + (0x4 << (i2c)->reg_shift)) 167 - #define _ICR(i2c) ((i2c)->reg_base + (0x8 << (i2c)->reg_shift)) 168 - #define _ISR(i2c) ((i2c)->reg_base + (0xc << (i2c)->reg_shift)) 169 - #define _ISAR(i2c) ((i2c)->reg_base + (0x10 << (i2c)->reg_shift)) 124 + #define _IBMR(i2c) ((i2c)->reg_ibmr) 125 + #define _IDBR(i2c) ((i2c)->reg_idbr) 126 + #define _ICR(i2c) ((i2c)->reg_icr) 127 + #define _ISR(i2c) ((i2c)->reg_isr) 128 + #define _ISAR(i2c) ((i2c)->reg_isar) 170 129 171 130 /* 172 131 * I2C Slave mode address ··· 459 418 writel(I2C_ISR_INIT, _ISR(i2c)); 460 419 writel(readl(_ICR(i2c)) & ~ICR_UR, _ICR(i2c)); 461 420 462 - writel(i2c->slave_addr, _ISAR(i2c)); 421 + if (i2c->reg_isar) 422 + writel(i2c->slave_addr, _ISAR(i2c)); 463 423 464 424 /* set control register values */ 465 425 writel(I2C_ICR_INIT | (i2c->fast_mode ? ICR_FM : 0), _ICR(i2c)); ··· 771 729 */ 772 730 ret = i2c->msg_idx; 773 731 774 - if (timeout == 0) 732 + if (!timeout && i2c->msg_num) { 775 733 i2c_pxa_scream_blue_murder(i2c, "timeout"); 734 + ret = I2C_RETRY; 735 + } 776 736 777 737 out: 778 738 return ret; ··· 959 915 writel(icr, _ICR(i2c)); 960 916 } 961 917 918 + #define VALID_INT_SOURCE (ISR_SSD | ISR_ALD | ISR_ITE | ISR_IRF | \ 919 + ISR_SAD | ISR_BED) 962 920 static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id) 963 921 { 964 922 struct pxa_i2c *i2c = dev_id; 965 923 u32 isr = readl(_ISR(i2c)); 924 + 925 + if (!(isr & VALID_INT_SOURCE)) 926 + return IRQ_NONE; 966 927 967 928 if (i2c_debug > 2 && 0) { 968 929 dev_dbg(&i2c->adap.dev, "%s: ISR=%08x, ICR=%08x, IBMR=%02x\n", ··· 983 934 /* 984 935 * Always clear all pending IRQs. 985 936 */ 986 - writel(isr & (ISR_SSD|ISR_ALD|ISR_ITE|ISR_IRF|ISR_SAD|ISR_BED), _ISR(i2c)); 937 + writel(isr & VALID_INT_SOURCE, _ISR(i2c)); 987 938 988 939 if (isr & ISR_SAD) 989 940 i2c_pxa_slave_start(i2c, isr); ··· 1050 1001 struct resource *res; 1051 1002 struct i2c_pxa_platform_data *plat = dev->dev.platform_data; 1052 1003 const struct platform_device_id *id = platform_get_device_id(dev); 1004 + enum pxa_i2c_types i2c_type = id->driver_data; 1053 1005 int ret; 1054 1006 int irq; 1055 1007 ··· 1094 1044 ret = -EIO; 1095 1045 goto eremap; 1096 1046 } 1097 - i2c->reg_shift = REG_SHIFT(id->driver_data); 1047 + 1048 + i2c->reg_ibmr = i2c->reg_base + pxa_reg_layout[i2c_type].ibmr; 1049 + i2c->reg_idbr = i2c->reg_base + pxa_reg_layout[i2c_type].idbr; 1050 + i2c->reg_icr = i2c->reg_base + pxa_reg_layout[i2c_type].icr; 1051 + i2c->reg_isr = i2c->reg_base + pxa_reg_layout[i2c_type].isr; 1052 + if (i2c_type != REGS_CE4100) 1053 + i2c->reg_isar = i2c->reg_base + pxa_reg_layout[i2c_type].isar; 1098 1054 1099 1055 i2c->iobase = res->start; 1100 1056 i2c->iosize = resource_size(res); ··· 1128 1072 i2c->adap.algo = &i2c_pxa_pio_algorithm; 1129 1073 } else { 1130 1074 i2c->adap.algo = &i2c_pxa_algorithm; 1131 - ret = request_irq(irq, i2c_pxa_handler, IRQF_DISABLED, 1075 + ret = request_irq(irq, i2c_pxa_handler, IRQF_SHARED, 1132 1076 i2c->adap.name, i2c); 1133 1077 if (ret) 1134 1078 goto ereqirq; ··· 1138 1082 1139 1083 i2c->adap.algo_data = i2c; 1140 1084 i2c->adap.dev.parent = &dev->dev; 1085 + #ifdef CONFIG_OF 1086 + i2c->adap.dev.of_node = dev->dev.of_node; 1087 + #endif 1141 1088 1142 - ret = i2c_add_numbered_adapter(&i2c->adap); 1089 + if (i2c_type == REGS_CE4100) 1090 + ret = i2c_add_adapter(&i2c->adap); 1091 + else 1092 + ret = i2c_add_numbered_adapter(&i2c->adap); 1143 1093 if (ret < 0) { 1144 1094 printk(KERN_INFO "I2C: Failed to add bus\n"); 1145 1095 goto eadapt; 1146 1096 } 1097 + of_i2c_register_devices(&i2c->adap); 1147 1098 1148 1099 platform_set_drvdata(dev, i2c); 1149 1100