diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-21 12:39:37 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-21 12:39:37 -0500 |
commit | 02d0a752460ea5dab34ce36c9ddc9c682e846a0d (patch) | |
tree | 094908b333a993b2160ee220f794a908a5e355b6 | |
parent | fb2e2c85375a0380d6818f153ffa2ae9ebbd055f (diff) | |
parent | 5f1b11555ef21fb3a8a9d21a2e5914e2bc1b9d9b (diff) |
Merge branch 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang:
"For 3.14, the I2C subsystem has the following to offer:
- new drivers for Renesas RIIC and RobotFuzz OSIF
- driver cleanups & improvements & bugfixes
Pretty standard stuff this time, I'd say. There is more complex stuff
coming up, but I didn't have the bandwidth between the years to pull
it in for this release. Sadly"
* 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (26 commits)
i2c: s3c2410: fix quirk usage for 64-bit
i2c: pnx: Use devm_*() functions
i2c: at91: add a new compatibility string for the at91sam9261
i2c-ismt: support I2C_SMBUS_I2C_BLOCK_DATA transaction type
i2c: Add bus driver for for OSIF USB i2c device.
i2c: i2c-tiny-usb: Remove RobotFuzz USB vendor:product ID
i2c: designware: remove HAVE_CLK build dependecy
Documentation: i2c: Remove obsolete example
i2c: nomadik: remove platform data header
i2c: nomadik: auto-calculate slave setup time
i2c: viperboard: remove superfluous assignment
i2c: xilinx: Use devm_* functions
i2c: xilinx: Do not enable irq before irq handler
i2c: xilinx: Fix i2c checkpatch warnings
i2c: at91: document clock properties
i2c: isch: Use devm_request_region()
i2c: viperboard: Use devm_kzalloc() functions
i2c: imx: propagate irq error code in probe
i2c: s3c2410: dont need CPU_FREQ transitions for exynos series
i2c: s3c2410: Add polling mode support
...
23 files changed, 964 insertions, 222 deletions
diff --git a/Documentation/devicetree/bindings/i2c/i2c-at91.txt b/Documentation/devicetree/bindings/i2c/i2c-at91.txt index b689a0d9441c..4fade84bea16 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-at91.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-at91.txt | |||
@@ -9,6 +9,7 @@ Required properties : | |||
9 | - interrupts: interrupt number to the cpu. | 9 | - interrupts: interrupt number to the cpu. |
10 | - #address-cells = <1>; | 10 | - #address-cells = <1>; |
11 | - #size-cells = <0>; | 11 | - #size-cells = <0>; |
12 | - clocks: phandles to input clocks. | ||
12 | 13 | ||
13 | Optional properties: | 14 | Optional properties: |
14 | - Child nodes conforming to i2c bus binding | 15 | - Child nodes conforming to i2c bus binding |
@@ -21,6 +22,7 @@ i2c0: i2c@fff84000 { | |||
21 | interrupts = <12 4 6>; | 22 | interrupts = <12 4 6>; |
22 | #address-cells = <1>; | 23 | #address-cells = <1>; |
23 | #size-cells = <0>; | 24 | #size-cells = <0>; |
25 | clocks = <&twi0_clk>; | ||
24 | 26 | ||
25 | 24c512@50 { | 27 | 24c512@50 { |
26 | compatible = "24c512"; | 28 | compatible = "24c512"; |
diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt new file mode 100644 index 000000000000..34a3fb6f8488 --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt | |||
@@ -0,0 +1,50 @@ | |||
1 | * NXP PCA954x I2C bus switch | ||
2 | |||
3 | Required Properties: | ||
4 | |||
5 | - compatible: Must contain one of the following. | ||
6 | "nxp,pca9540", "nxp,pca9542", "nxp,pca9543", "nxp,pca9544", | ||
7 | "nxp,pca9545", "nxp,pca9546", "nxp,pca9547", "nxp,pca9548" | ||
8 | |||
9 | - reg: The I2C address of the device. | ||
10 | |||
11 | The following required properties are defined externally: | ||
12 | |||
13 | - Standard I2C mux properties. See i2c-mux.txt in this directory. | ||
14 | - I2C child bus nodes. See i2c-mux.txt in this directory. | ||
15 | |||
16 | Optional Properties: | ||
17 | |||
18 | - reset-gpios: Reference to the GPIO connected to the reset input. | ||
19 | |||
20 | |||
21 | Example: | ||
22 | |||
23 | i2c-switch@74 { | ||
24 | compatible = "nxp,pca9548"; | ||
25 | #address-cells = <1>; | ||
26 | #size-cells = <0>; | ||
27 | reg = <0x74>; | ||
28 | |||
29 | i2c@2 { | ||
30 | #address-cells = <1>; | ||
31 | #size-cells = <0>; | ||
32 | reg = <2>; | ||
33 | |||
34 | eeprom@54 { | ||
35 | compatible = "at,24c08"; | ||
36 | reg = <0x54>; | ||
37 | }; | ||
38 | }; | ||
39 | |||
40 | i2c@4 { | ||
41 | #address-cells = <1>; | ||
42 | #size-cells = <0>; | ||
43 | reg = <4>; | ||
44 | |||
45 | rtc@51 { | ||
46 | compatible = "nxp,pcf8563"; | ||
47 | reg = <0x51>; | ||
48 | }; | ||
49 | }; | ||
50 | }; | ||
diff --git a/Documentation/devicetree/bindings/i2c/i2c-riic.txt b/Documentation/devicetree/bindings/i2c/i2c-riic.txt new file mode 100644 index 000000000000..0bcc4716c319 --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/i2c-riic.txt | |||
@@ -0,0 +1,29 @@ | |||
1 | Device tree configuration for Renesas RIIC driver | ||
2 | |||
3 | Required properties: | ||
4 | - compatible : "renesas,riic-<soctype>". "renesas,riic-rz" as fallback | ||
5 | - reg : address start and address range size of device | ||
6 | - interrupts : 8 interrupts (TEI, RI, TI, SPI, STI, NAKI, ALI, TMOI) | ||
7 | - clock-frequency : frequency of bus clock in Hz | ||
8 | - #address-cells : should be <1> | ||
9 | - #size-cells : should be <0> | ||
10 | |||
11 | Pinctrl properties might be needed, too. See there. | ||
12 | |||
13 | Example: | ||
14 | |||
15 | i2c0: i2c@fcfee000 { | ||
16 | compatible = "renesas,riic-r7s72100", "renesas,riic-rz"; | ||
17 | reg = <0xfcfee000 0x44>; | ||
18 | interrupts = <0 157 IRQ_TYPE_LEVEL_HIGH>, | ||
19 | <0 158 IRQ_TYPE_EDGE_RISING>, | ||
20 | <0 159 IRQ_TYPE_EDGE_RISING>, | ||
21 | <0 160 IRQ_TYPE_LEVEL_HIGH>, | ||
22 | <0 161 IRQ_TYPE_LEVEL_HIGH>, | ||
23 | <0 162 IRQ_TYPE_LEVEL_HIGH>, | ||
24 | <0 163 IRQ_TYPE_LEVEL_HIGH>, | ||
25 | <0 164 IRQ_TYPE_LEVEL_HIGH>; | ||
26 | clock-frequency = <100000>; | ||
27 | #address-cells = <1>; | ||
28 | #size-cells = <0>; | ||
29 | }; | ||
diff --git a/Documentation/devicetree/bindings/i2c/i2c-s3c2410.txt b/Documentation/devicetree/bindings/i2c/i2c-s3c2410.txt index 296eb4536129..278de8e64bbf 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-s3c2410.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-s3c2410.txt | |||
@@ -10,6 +10,8 @@ Required properties: | |||
10 | inside HDMIPHY block found on several samsung SoCs | 10 | inside HDMIPHY block found on several samsung SoCs |
11 | (d) "samsung, exynos5440-i2c", for s3c2440-like i2c used | 11 | (d) "samsung, exynos5440-i2c", for s3c2440-like i2c used |
12 | on EXYNOS5440 which does not need GPIO configuration. | 12 | on EXYNOS5440 which does not need GPIO configuration. |
13 | (e) "samsung, exynos5-sata-phy-i2c", for s3c2440-like i2c used as | ||
14 | a host to SATA PHY controller on an internal bus. | ||
13 | - reg: physical base address of the controller and length of memory mapped | 15 | - reg: physical base address of the controller and length of memory mapped |
14 | region. | 16 | region. |
15 | - interrupts: interrupt number to the cpu. | 17 | - interrupts: interrupt number to the cpu. |
diff --git a/Documentation/i2c/fault-codes b/Documentation/i2c/fault-codes index 045765c0b9b5..47c25abb7d52 100644 --- a/Documentation/i2c/fault-codes +++ b/Documentation/i2c/fault-codes | |||
@@ -64,9 +64,6 @@ EINVAL | |||
64 | detected before any I/O operation was started. Use a more | 64 | detected before any I/O operation was started. Use a more |
65 | specific fault code when you can. | 65 | specific fault code when you can. |
66 | 66 | ||
67 | One example would be a driver trying an SMBus Block Write | ||
68 | with block size outside the range of 1-32 bytes. | ||
69 | |||
70 | EIO | 67 | EIO |
71 | This rather vague error means something went wrong when | 68 | This rather vague error means something went wrong when |
72 | performing an I/O operation. Use a more specific fault | 69 | performing an I/O operation. Use a more specific fault |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 3b26129f6055..6bcdea5856af 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -412,7 +412,6 @@ config I2C_DESIGNWARE_CORE | |||
412 | 412 | ||
413 | config I2C_DESIGNWARE_PLATFORM | 413 | config I2C_DESIGNWARE_PLATFORM |
414 | tristate "Synopsys DesignWare Platform" | 414 | tristate "Synopsys DesignWare Platform" |
415 | depends on HAVE_CLK | ||
416 | select I2C_DESIGNWARE_CORE | 415 | select I2C_DESIGNWARE_CORE |
417 | help | 416 | help |
418 | If you say yes to this option, support will be included for the | 417 | If you say yes to this option, support will be included for the |
@@ -648,6 +647,16 @@ config I2C_PXA_SLAVE | |||
648 | is necessary for systems where the PXA may be a target on the | 647 | is necessary for systems where the PXA may be a target on the |
649 | I2C bus. | 648 | I2C bus. |
650 | 649 | ||
650 | config I2C_RIIC | ||
651 | tristate "Renesas RIIC adapter" | ||
652 | depends on ARCH_SHMOBILE || COMPILE_TEST | ||
653 | help | ||
654 | If you say yes to this option, support will be included for the | ||
655 | Renesas RIIC I2C interface. | ||
656 | |||
657 | This driver can also be built as a module. If so, the module | ||
658 | will be called i2c-riic. | ||
659 | |||
651 | config HAVE_S3C2410_I2C | 660 | config HAVE_S3C2410_I2C |
652 | bool | 661 | bool |
653 | help | 662 | help |
@@ -683,7 +692,7 @@ config I2C_SH7760 | |||
683 | 692 | ||
684 | config I2C_SH_MOBILE | 693 | config I2C_SH_MOBILE |
685 | tristate "SuperH Mobile I2C Controller" | 694 | tristate "SuperH Mobile I2C Controller" |
686 | depends on SUPERH || ARM || COMPILE_TEST | 695 | depends on SUPERH || ARCH_SHMOBILE || COMPILE_TEST |
687 | help | 696 | help |
688 | If you say yes to this option, support will be included for the | 697 | If you say yes to this option, support will be included for the |
689 | built-in I2C interface on the Renesas SH-Mobile processor. | 698 | built-in I2C interface on the Renesas SH-Mobile processor. |
@@ -796,7 +805,7 @@ config I2C_XLR | |||
796 | 805 | ||
797 | config I2C_RCAR | 806 | config I2C_RCAR |
798 | tristate "Renesas R-Car I2C Controller" | 807 | tristate "Renesas R-Car I2C Controller" |
799 | depends on ARM || COMPILE_TEST | 808 | depends on ARCH_SHMOBILE || COMPILE_TEST |
800 | help | 809 | help |
801 | If you say yes to this option, support will be included for the | 810 | If you say yes to this option, support will be included for the |
802 | R-Car I2C controller. | 811 | R-Car I2C controller. |
@@ -865,6 +874,16 @@ config I2C_PARPORT_LIGHT | |||
865 | This support is also available as a module. If so, the module | 874 | This support is also available as a module. If so, the module |
866 | will be called i2c-parport-light. | 875 | will be called i2c-parport-light. |
867 | 876 | ||
877 | config I2C_ROBOTFUZZ_OSIF | ||
878 | tristate "RobotFuzz Open Source InterFace USB adapter" | ||
879 | depends on USB | ||
880 | help | ||
881 | If you say yes to this option, support will be included for the | ||
882 | RobotFuzz Open Source InterFace USB to I2C interface. | ||
883 | |||
884 | This driver can also be built as a module. If so, the module | ||
885 | will be called i2c-osif. | ||
886 | |||
868 | config I2C_TAOS_EVM | 887 | config I2C_TAOS_EVM |
869 | tristate "TAOS evaluation module" | 888 | tristate "TAOS evaluation module" |
870 | depends on TTY | 889 | depends on TTY |
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index c73eb0ea788e..a08931fe73e1 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile | |||
@@ -63,6 +63,7 @@ obj-$(CONFIG_I2C_PNX) += i2c-pnx.o | |||
63 | obj-$(CONFIG_I2C_PUV3) += i2c-puv3.o | 63 | obj-$(CONFIG_I2C_PUV3) += i2c-puv3.o |
64 | obj-$(CONFIG_I2C_PXA) += i2c-pxa.o | 64 | obj-$(CONFIG_I2C_PXA) += i2c-pxa.o |
65 | obj-$(CONFIG_I2C_PXA_PCI) += i2c-pxa-pci.o | 65 | obj-$(CONFIG_I2C_PXA_PCI) += i2c-pxa-pci.o |
66 | obj-$(CONFIG_I2C_RIIC) += i2c-riic.o | ||
66 | obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o | 67 | obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o |
67 | obj-$(CONFIG_I2C_S6000) += i2c-s6000.o | 68 | obj-$(CONFIG_I2C_S6000) += i2c-s6000.o |
68 | obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o | 69 | obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o |
@@ -83,6 +84,7 @@ obj-$(CONFIG_I2C_RCAR) += i2c-rcar.o | |||
83 | obj-$(CONFIG_I2C_DIOLAN_U2C) += i2c-diolan-u2c.o | 84 | obj-$(CONFIG_I2C_DIOLAN_U2C) += i2c-diolan-u2c.o |
84 | obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o | 85 | obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o |
85 | obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o | 86 | obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o |
87 | obj-$(CONFIG_I2C_ROBOTFUZZ_OSIF) += i2c-robotfuzz-osif.o | ||
86 | obj-$(CONFIG_I2C_TAOS_EVM) += i2c-taos-evm.o | 88 | obj-$(CONFIG_I2C_TAOS_EVM) += i2c-taos-evm.o |
87 | obj-$(CONFIG_I2C_TINY_USB) += i2c-tiny-usb.o | 89 | obj-$(CONFIG_I2C_TINY_USB) += i2c-tiny-usb.o |
88 | obj-$(CONFIG_I2C_VIPERBOARD) += i2c-viperboard.o | 90 | obj-$(CONFIG_I2C_VIPERBOARD) += i2c-viperboard.o |
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index 8edba9de76df..843d01268ae9 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c | |||
@@ -589,6 +589,9 @@ static const struct of_device_id atmel_twi_dt_ids[] = { | |||
589 | .compatible = "atmel,at91sam9260-i2c", | 589 | .compatible = "atmel,at91sam9260-i2c", |
590 | .data = &at91sam9260_config, | 590 | .data = &at91sam9260_config, |
591 | } , { | 591 | } , { |
592 | .compatible = "atmel,at91sam9261-i2c", | ||
593 | .data = &at91sam9261_config, | ||
594 | } , { | ||
592 | .compatible = "atmel,at91sam9g20-i2c", | 595 | .compatible = "atmel,at91sam9g20-i2c", |
593 | .data = &at91sam9g20_config, | 596 | .data = &at91sam9g20_config, |
594 | } , { | 597 | } , { |
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c index e89e3e2145e5..14c4b30d4ccc 100644 --- a/drivers/i2c/busses/i2c-designware-core.c +++ b/drivers/i2c/busses/i2c-designware-core.c | |||
@@ -26,7 +26,6 @@ | |||
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | #include <linux/export.h> | 28 | #include <linux/export.h> |
29 | #include <linux/clk.h> | ||
30 | #include <linux/errno.h> | 29 | #include <linux/errno.h> |
31 | #include <linux/err.h> | 30 | #include <linux/err.h> |
32 | #include <linux/i2c.h> | 31 | #include <linux/i2c.h> |
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index d0cfbb4cb964..db895fb22e65 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c | |||
@@ -607,7 +607,7 @@ static int i2c_imx_probe(struct platform_device *pdev) | |||
607 | irq = platform_get_irq(pdev, 0); | 607 | irq = platform_get_irq(pdev, 0); |
608 | if (irq < 0) { | 608 | if (irq < 0) { |
609 | dev_err(&pdev->dev, "can't get irq number\n"); | 609 | dev_err(&pdev->dev, "can't get irq number\n"); |
610 | return -ENOENT; | 610 | return irq; |
611 | } | 611 | } |
612 | 612 | ||
613 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 613 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index 8c38aaa7417c..af213045ab7e 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c | |||
@@ -275,7 +275,8 @@ static int smbus_sch_probe(struct platform_device *dev) | |||
275 | if (!res) | 275 | if (!res) |
276 | return -EBUSY; | 276 | return -EBUSY; |
277 | 277 | ||
278 | if (!request_region(res->start, resource_size(res), dev->name)) { | 278 | if (!devm_request_region(&dev->dev, res->start, resource_size(res), |
279 | dev->name)) { | ||
279 | dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", | 280 | dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", |
280 | sch_smba); | 281 | sch_smba); |
281 | return -EBUSY; | 282 | return -EBUSY; |
@@ -294,7 +295,6 @@ static int smbus_sch_probe(struct platform_device *dev) | |||
294 | retval = i2c_add_adapter(&sch_adapter); | 295 | retval = i2c_add_adapter(&sch_adapter); |
295 | if (retval) { | 296 | if (retval) { |
296 | dev_err(&dev->dev, "Couldn't register adapter!\n"); | 297 | dev_err(&dev->dev, "Couldn't register adapter!\n"); |
297 | release_region(res->start, resource_size(res)); | ||
298 | sch_smba = 0; | 298 | sch_smba = 0; |
299 | } | 299 | } |
300 | 300 | ||
@@ -303,11 +303,8 @@ static int smbus_sch_probe(struct platform_device *dev) | |||
303 | 303 | ||
304 | static int smbus_sch_remove(struct platform_device *pdev) | 304 | static int smbus_sch_remove(struct platform_device *pdev) |
305 | { | 305 | { |
306 | struct resource *res; | ||
307 | if (sch_smba) { | 306 | if (sch_smba) { |
308 | i2c_del_adapter(&sch_adapter); | 307 | i2c_del_adapter(&sch_adapter); |
309 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
310 | release_region(res->start, resource_size(res)); | ||
311 | sch_smba = 0; | 308 | sch_smba = 0; |
312 | } | 309 | } |
313 | 310 | ||
diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c index 0043ede234c2..bb132ea7d2b4 100644 --- a/drivers/i2c/busses/i2c-ismt.c +++ b/drivers/i2c/busses/i2c-ismt.c | |||
@@ -344,6 +344,7 @@ static int ismt_process_desc(const struct ismt_desc *desc, | |||
344 | data->word = dma_buffer[0] | (dma_buffer[1] << 8); | 344 | data->word = dma_buffer[0] | (dma_buffer[1] << 8); |
345 | break; | 345 | break; |
346 | case I2C_SMBUS_BLOCK_DATA: | 346 | case I2C_SMBUS_BLOCK_DATA: |
347 | case I2C_SMBUS_I2C_BLOCK_DATA: | ||
347 | memcpy(&data->block[1], dma_buffer, desc->rxbytes); | 348 | memcpy(&data->block[1], dma_buffer, desc->rxbytes); |
348 | data->block[0] = desc->rxbytes; | 349 | data->block[0] = desc->rxbytes; |
349 | break; | 350 | break; |
@@ -509,6 +510,41 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr, | |||
509 | } | 510 | } |
510 | break; | 511 | break; |
511 | 512 | ||
513 | case I2C_SMBUS_I2C_BLOCK_DATA: | ||
514 | /* Make sure the length is valid */ | ||
515 | if (data->block[0] < 1) | ||
516 | data->block[0] = 1; | ||
517 | |||
518 | if (data->block[0] > I2C_SMBUS_BLOCK_MAX) | ||
519 | data->block[0] = I2C_SMBUS_BLOCK_MAX; | ||
520 | |||
521 | if (read_write == I2C_SMBUS_WRITE) { | ||
522 | /* i2c Block Write */ | ||
523 | dev_dbg(dev, "I2C_SMBUS_I2C_BLOCK_DATA: WRITE\n"); | ||
524 | dma_size = data->block[0] + 1; | ||
525 | dma_direction = DMA_TO_DEVICE; | ||
526 | desc->wr_len_cmd = dma_size; | ||
527 | desc->control |= ISMT_DESC_I2C; | ||
528 | priv->dma_buffer[0] = command; | ||
529 | memcpy(&priv->dma_buffer[1], &data->block[1], dma_size); | ||
530 | } else { | ||
531 | /* i2c Block Read */ | ||
532 | dev_dbg(dev, "I2C_SMBUS_I2C_BLOCK_DATA: READ\n"); | ||
533 | dma_size = data->block[0]; | ||
534 | dma_direction = DMA_FROM_DEVICE; | ||
535 | desc->rd_len = dma_size; | ||
536 | desc->wr_len_cmd = command; | ||
537 | desc->control |= (ISMT_DESC_I2C | ISMT_DESC_CWRL); | ||
538 | /* | ||
539 | * Per the "Table 15-15. I2C Commands", | ||
540 | * in the External Design Specification (EDS), | ||
541 | * (Document Number: 508084, Revision: 2.0), | ||
542 | * the _rw bit must be 0 | ||
543 | */ | ||
544 | desc->tgtaddr_rw = ISMT_DESC_ADDR_RW(addr, 0); | ||
545 | } | ||
546 | break; | ||
547 | |||
512 | default: | 548 | default: |
513 | dev_err(dev, "Unsupported transaction %d\n", | 549 | dev_err(dev, "Unsupported transaction %d\n", |
514 | size); | 550 | size); |
@@ -582,6 +618,7 @@ static u32 ismt_func(struct i2c_adapter *adap) | |||
582 | I2C_FUNC_SMBUS_WORD_DATA | | 618 | I2C_FUNC_SMBUS_WORD_DATA | |
583 | I2C_FUNC_SMBUS_PROC_CALL | | 619 | I2C_FUNC_SMBUS_PROC_CALL | |
584 | I2C_FUNC_SMBUS_BLOCK_DATA | | 620 | I2C_FUNC_SMBUS_BLOCK_DATA | |
621 | I2C_FUNC_SMBUS_I2C_BLOCK | | ||
585 | I2C_FUNC_SMBUS_PEC; | 622 | I2C_FUNC_SMBUS_PEC; |
586 | } | 623 | } |
587 | 624 | ||
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 8bf9ac01301a..4443613514ee 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/clk.h> | 22 | #include <linux/clk.h> |
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <linux/pm_runtime.h> | 24 | #include <linux/pm_runtime.h> |
25 | #include <linux/platform_data/i2c-nomadik.h> | ||
26 | #include <linux/of.h> | 25 | #include <linux/of.h> |
27 | #include <linux/pinctrl/consumer.h> | 26 | #include <linux/pinctrl/consumer.h> |
28 | 27 | ||
@@ -104,6 +103,29 @@ | |||
104 | /* maximum threshold value */ | 103 | /* maximum threshold value */ |
105 | #define MAX_I2C_FIFO_THRESHOLD 15 | 104 | #define MAX_I2C_FIFO_THRESHOLD 15 |
106 | 105 | ||
106 | enum i2c_freq_mode { | ||
107 | I2C_FREQ_MODE_STANDARD, /* up to 100 Kb/s */ | ||
108 | I2C_FREQ_MODE_FAST, /* up to 400 Kb/s */ | ||
109 | I2C_FREQ_MODE_HIGH_SPEED, /* up to 3.4 Mb/s */ | ||
110 | I2C_FREQ_MODE_FAST_PLUS, /* up to 1 Mb/s */ | ||
111 | }; | ||
112 | |||
113 | /** | ||
114 | * struct nmk_i2c_controller - client specific controller configuration | ||
115 | * @clk_freq: clock frequency for the operation mode | ||
116 | * @tft: Tx FIFO Threshold in bytes | ||
117 | * @rft: Rx FIFO Threshold in bytes | ||
118 | * @timeout Slave response timeout(ms) | ||
119 | * @sm: speed mode | ||
120 | */ | ||
121 | struct nmk_i2c_controller { | ||
122 | u32 clk_freq; | ||
123 | unsigned char tft; | ||
124 | unsigned char rft; | ||
125 | int timeout; | ||
126 | enum i2c_freq_mode sm; | ||
127 | }; | ||
128 | |||
107 | /** | 129 | /** |
108 | * struct i2c_vendor_data - per-vendor variations | 130 | * struct i2c_vendor_data - per-vendor variations |
109 | * @has_mtdws: variant has the MTDWS bit | 131 | * @has_mtdws: variant has the MTDWS bit |
@@ -340,6 +362,8 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev) | |||
340 | { | 362 | { |
341 | u32 brcr1, brcr2; | 363 | u32 brcr1, brcr2; |
342 | u32 i2c_clk, div; | 364 | u32 i2c_clk, div; |
365 | u32 ns; | ||
366 | u16 slsu; | ||
343 | 367 | ||
344 | writel(0x0, dev->virtbase + I2C_CR); | 368 | writel(0x0, dev->virtbase + I2C_CR); |
345 | writel(0x0, dev->virtbase + I2C_HSMCR); | 369 | writel(0x0, dev->virtbase + I2C_HSMCR); |
@@ -347,18 +371,38 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev) | |||
347 | writel(0x0, dev->virtbase + I2C_RFTR); | 371 | writel(0x0, dev->virtbase + I2C_RFTR); |
348 | writel(0x0, dev->virtbase + I2C_DMAR); | 372 | writel(0x0, dev->virtbase + I2C_DMAR); |
349 | 373 | ||
374 | i2c_clk = clk_get_rate(dev->clk); | ||
375 | |||
350 | /* | 376 | /* |
351 | * set the slsu: | 377 | * set the slsu: |
352 | * | 378 | * |
353 | * slsu defines the data setup time after SCL clock | 379 | * slsu defines the data setup time after SCL clock |
354 | * stretching in terms of i2c clk cycles. The | 380 | * stretching in terms of i2c clk cycles + 1 (zero means |
355 | * needed setup time for the three modes are 250ns, | 381 | * "wait one cycle"), the needed setup time for the three |
356 | * 100ns, 10ns respectively thus leading to the values | 382 | * modes are 250ns, 100ns, 10ns respectively. |
357 | * of 14, 6, 2 for a 48 MHz i2c clk. | 383 | * |
384 | * As the time for one cycle T in nanoseconds is | ||
385 | * T = (1/f) * 1000000000 => | ||
386 | * slsu = cycles / (1000000000 / f) + 1 | ||
358 | */ | 387 | */ |
359 | writel(dev->cfg.slsu << 16, dev->virtbase + I2C_SCR); | 388 | ns = DIV_ROUND_UP_ULL(1000000000ULL, i2c_clk); |
389 | switch (dev->cfg.sm) { | ||
390 | case I2C_FREQ_MODE_FAST: | ||
391 | case I2C_FREQ_MODE_FAST_PLUS: | ||
392 | slsu = DIV_ROUND_UP(100, ns); /* Fast */ | ||
393 | break; | ||
394 | case I2C_FREQ_MODE_HIGH_SPEED: | ||
395 | slsu = DIV_ROUND_UP(10, ns); /* High */ | ||
396 | break; | ||
397 | case I2C_FREQ_MODE_STANDARD: | ||
398 | default: | ||
399 | slsu = DIV_ROUND_UP(250, ns); /* Standard */ | ||
400 | break; | ||
401 | } | ||
402 | slsu += 1; | ||
360 | 403 | ||
361 | i2c_clk = clk_get_rate(dev->clk); | 404 | dev_dbg(&dev->adev->dev, "calculated SLSU = %04x\n", slsu); |
405 | writel(slsu << 16, dev->virtbase + I2C_SCR); | ||
362 | 406 | ||
363 | /* | 407 | /* |
364 | * The spec says, in case of std. mode the divider is | 408 | * The spec says, in case of std. mode the divider is |
@@ -915,11 +959,6 @@ static const struct i2c_algorithm nmk_i2c_algo = { | |||
915 | }; | 959 | }; |
916 | 960 | ||
917 | static struct nmk_i2c_controller u8500_i2c = { | 961 | static struct nmk_i2c_controller u8500_i2c = { |
918 | /* | ||
919 | * Slave data setup time; 250ns, 100ns, and 10ns, which | ||
920 | * is 14, 6 and 2 respectively for a 48Mhz i2c clock. | ||
921 | */ | ||
922 | .slsu = 0xe, | ||
923 | .tft = 1, /* Tx FIFO threshold */ | 962 | .tft = 1, /* Tx FIFO threshold */ |
924 | .rft = 8, /* Rx FIFO threshold */ | 963 | .rft = 8, /* Rx FIFO threshold */ |
925 | .clk_freq = 400000, /* fast mode operation */ | 964 | .clk_freq = 400000, /* fast mode operation */ |
@@ -1027,7 +1066,6 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) | |||
1027 | 1066 | ||
1028 | /* fetch the controller configuration from machine */ | 1067 | /* fetch the controller configuration from machine */ |
1029 | dev->cfg.clk_freq = pdata->clk_freq; | 1068 | dev->cfg.clk_freq = pdata->clk_freq; |
1030 | dev->cfg.slsu = pdata->slsu; | ||
1031 | dev->cfg.tft = pdata->tft; | 1069 | dev->cfg.tft = pdata->tft; |
1032 | dev->cfg.rft = pdata->rft; | 1070 | dev->cfg.rft = pdata->rft; |
1033 | dev->cfg.sm = pdata->sm; | 1071 | dev->cfg.sm = pdata->sm; |
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c index c9a352f0a9a5..dc7ff829ad78 100644 --- a/drivers/i2c/busses/i2c-pnx.c +++ b/drivers/i2c/busses/i2c-pnx.c | |||
@@ -628,11 +628,9 @@ static int i2c_pnx_probe(struct platform_device *pdev) | |||
628 | struct resource *res; | 628 | struct resource *res; |
629 | u32 speed = I2C_PNX_SPEED_KHZ_DEFAULT * 1000; | 629 | u32 speed = I2C_PNX_SPEED_KHZ_DEFAULT * 1000; |
630 | 630 | ||
631 | alg_data = kzalloc(sizeof(*alg_data), GFP_KERNEL); | 631 | alg_data = devm_kzalloc(&pdev->dev, sizeof(*alg_data), GFP_KERNEL); |
632 | if (!alg_data) { | 632 | if (!alg_data) |
633 | ret = -ENOMEM; | 633 | return -ENOMEM; |
634 | goto err_kzalloc; | ||
635 | } | ||
636 | 634 | ||
637 | platform_set_drvdata(pdev, alg_data); | 635 | platform_set_drvdata(pdev, alg_data); |
638 | 636 | ||
@@ -657,11 +655,9 @@ static int i2c_pnx_probe(struct platform_device *pdev) | |||
657 | */ | 655 | */ |
658 | } | 656 | } |
659 | #endif | 657 | #endif |
660 | alg_data->clk = clk_get(&pdev->dev, NULL); | 658 | alg_data->clk = devm_clk_get(&pdev->dev, NULL); |
661 | if (IS_ERR(alg_data->clk)) { | 659 | if (IS_ERR(alg_data->clk)) |
662 | ret = PTR_ERR(alg_data->clk); | 660 | return PTR_ERR(alg_data->clk); |
663 | goto out_drvdata; | ||
664 | } | ||
665 | 661 | ||
666 | init_timer(&alg_data->mif.timer); | 662 | init_timer(&alg_data->mif.timer); |
667 | alg_data->mif.timer.function = i2c_pnx_timeout; | 663 | alg_data->mif.timer.function = i2c_pnx_timeout; |
@@ -672,31 +668,13 @@ static int i2c_pnx_probe(struct platform_device *pdev) | |||
672 | 668 | ||
673 | /* Register I/O resource */ | 669 | /* Register I/O resource */ |
674 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 670 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
675 | if (!res) { | 671 | alg_data->ioaddr = devm_ioremap_resource(&pdev->dev, res); |
676 | dev_err(&pdev->dev, "Unable to get mem resource.\n"); | 672 | if (IS_ERR(alg_data->ioaddr)) |
677 | ret = -EBUSY; | 673 | return PTR_ERR(alg_data->ioaddr); |
678 | goto out_clkget; | ||
679 | } | ||
680 | if (!request_mem_region(res->start, I2C_PNX_REGION_SIZE, | ||
681 | pdev->name)) { | ||
682 | dev_err(&pdev->dev, | ||
683 | "I/O region 0x%08x for I2C already in use.\n", | ||
684 | res->start); | ||
685 | ret = -ENOMEM; | ||
686 | goto out_clkget; | ||
687 | } | ||
688 | |||
689 | alg_data->base = res->start; | ||
690 | alg_data->ioaddr = ioremap(res->start, I2C_PNX_REGION_SIZE); | ||
691 | if (!alg_data->ioaddr) { | ||
692 | dev_err(&pdev->dev, "Couldn't ioremap I2C I/O region\n"); | ||
693 | ret = -ENOMEM; | ||
694 | goto out_release; | ||
695 | } | ||
696 | 674 | ||
697 | ret = clk_enable(alg_data->clk); | 675 | ret = clk_enable(alg_data->clk); |
698 | if (ret) | 676 | if (ret) |
699 | goto out_unmap; | 677 | return ret; |
700 | 678 | ||
701 | freq = clk_get_rate(alg_data->clk); | 679 | freq = clk_get_rate(alg_data->clk); |
702 | 680 | ||
@@ -730,8 +708,8 @@ static int i2c_pnx_probe(struct platform_device *pdev) | |||
730 | ret = alg_data->irq; | 708 | ret = alg_data->irq; |
731 | goto out_clock; | 709 | goto out_clock; |
732 | } | 710 | } |
733 | ret = request_irq(alg_data->irq, i2c_pnx_interrupt, | 711 | ret = devm_request_irq(&pdev->dev, alg_data->irq, i2c_pnx_interrupt, |
734 | 0, pdev->name, alg_data); | 712 | 0, pdev->name, alg_data); |
735 | if (ret) | 713 | if (ret) |
736 | goto out_clock; | 714 | goto out_clock; |
737 | 715 | ||
@@ -739,7 +717,7 @@ static int i2c_pnx_probe(struct platform_device *pdev) | |||
739 | ret = i2c_add_numbered_adapter(&alg_data->adapter); | 717 | ret = i2c_add_numbered_adapter(&alg_data->adapter); |
740 | if (ret < 0) { | 718 | if (ret < 0) { |
741 | dev_err(&pdev->dev, "I2C: Failed to add bus\n"); | 719 | dev_err(&pdev->dev, "I2C: Failed to add bus\n"); |
742 | goto out_irq; | 720 | goto out_clock; |
743 | } | 721 | } |
744 | 722 | ||
745 | dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n", | 723 | dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n", |
@@ -747,19 +725,8 @@ static int i2c_pnx_probe(struct platform_device *pdev) | |||
747 | 725 | ||
748 | return 0; | 726 | return 0; |
749 | 727 | ||
750 | out_irq: | ||
751 | free_irq(alg_data->irq, alg_data); | ||
752 | out_clock: | 728 | out_clock: |
753 | clk_disable(alg_data->clk); | 729 | clk_disable(alg_data->clk); |
754 | out_unmap: | ||
755 | iounmap(alg_data->ioaddr); | ||
756 | out_release: | ||
757 | release_mem_region(res->start, I2C_PNX_REGION_SIZE); | ||
758 | out_clkget: | ||
759 | clk_put(alg_data->clk); | ||
760 | out_drvdata: | ||
761 | kfree(alg_data); | ||
762 | err_kzalloc: | ||
763 | return ret; | 730 | return ret; |
764 | } | 731 | } |
765 | 732 | ||
@@ -767,13 +734,8 @@ static int i2c_pnx_remove(struct platform_device *pdev) | |||
767 | { | 734 | { |
768 | struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev); | 735 | struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev); |
769 | 736 | ||
770 | free_irq(alg_data->irq, alg_data); | ||
771 | i2c_del_adapter(&alg_data->adapter); | 737 | i2c_del_adapter(&alg_data->adapter); |
772 | clk_disable(alg_data->clk); | 738 | clk_disable(alg_data->clk); |
773 | iounmap(alg_data->ioaddr); | ||
774 | release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE); | ||
775 | clk_put(alg_data->clk); | ||
776 | kfree(alg_data); | ||
777 | 739 | ||
778 | return 0; | 740 | return 0; |
779 | } | 741 | } |
diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c new file mode 100644 index 000000000000..9e1f8bacfb39 --- /dev/null +++ b/drivers/i2c/busses/i2c-riic.c | |||
@@ -0,0 +1,427 @@ | |||
1 | /* | ||
2 | * Renesas RIIC driver | ||
3 | * | ||
4 | * Copyright (C) 2013 Wolfram Sang <wsa@sang-engineering.com> | ||
5 | * Copyright (C) 2013 Renesas Solutions Corp. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License version 2 as published by | ||
9 | * the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | /* | ||
13 | * This i2c core has a lot of interrupts, namely 8. We use their chaining as | ||
14 | * some kind of state machine. | ||
15 | * | ||
16 | * 1) The main xfer routine kicks off a transmission by putting the start bit | ||
17 | * (or repeated start) on the bus and enabling the transmit interrupt (TIE) | ||
18 | * since we need to send the slave address + RW bit in every case. | ||
19 | * | ||
20 | * 2) TIE sends slave address + RW bit and selects how to continue. | ||
21 | * | ||
22 | * 3a) Write case: We keep utilizing TIE as long as we have data to send. If we | ||
23 | * are done, we switch over to the transmission done interrupt (TEIE) and mark | ||
24 | * the message as completed (includes sending STOP) there. | ||
25 | * | ||
26 | * 3b) Read case: We switch over to receive interrupt (RIE). One dummy read is | ||
27 | * needed to start clocking, then we keep receiving until we are done. Note | ||
28 | * that we use the RDRFS mode all the time, i.e. we ACK/NACK every byte by | ||
29 | * writing to the ACKBT bit. I tried using the RDRFS mode only at the end of a | ||
30 | * message to create the final NACK as sketched in the datasheet. This caused | ||
31 | * some subtle races (when byte n was processed and byte n+1 was already | ||
32 | * waiting), though, and I started with the safe approach. | ||
33 | * | ||
34 | * 4) If we got a NACK somewhere, we flag the error and stop the transmission | ||
35 | * via NAKIE. | ||
36 | * | ||
37 | * Also check the comments in the interrupt routines for some gory details. | ||
38 | */ | ||
39 | |||
40 | #include <linux/clk.h> | ||
41 | #include <linux/completion.h> | ||
42 | #include <linux/err.h> | ||
43 | #include <linux/i2c.h> | ||
44 | #include <linux/interrupt.h> | ||
45 | #include <linux/io.h> | ||
46 | #include <linux/module.h> | ||
47 | #include <linux/of.h> | ||
48 | #include <linux/platform_device.h> | ||
49 | |||
50 | #define RIIC_ICCR1 0x00 | ||
51 | #define RIIC_ICCR2 0x04 | ||
52 | #define RIIC_ICMR1 0x08 | ||
53 | #define RIIC_ICMR3 0x10 | ||
54 | #define RIIC_ICSER 0x18 | ||
55 | #define RIIC_ICIER 0x1c | ||
56 | #define RIIC_ICSR2 0x24 | ||
57 | #define RIIC_ICBRL 0x34 | ||
58 | #define RIIC_ICBRH 0x38 | ||
59 | #define RIIC_ICDRT 0x3c | ||
60 | #define RIIC_ICDRR 0x40 | ||
61 | |||
62 | #define ICCR1_ICE 0x80 | ||
63 | #define ICCR1_IICRST 0x40 | ||
64 | #define ICCR1_SOWP 0x10 | ||
65 | |||
66 | #define ICCR2_BBSY 0x80 | ||
67 | #define ICCR2_SP 0x08 | ||
68 | #define ICCR2_RS 0x04 | ||
69 | #define ICCR2_ST 0x02 | ||
70 | |||
71 | #define ICMR1_CKS_MASK 0x70 | ||
72 | #define ICMR1_BCWP 0x08 | ||
73 | #define ICMR1_CKS(_x) ((((_x) << 4) & ICMR1_CKS_MASK) | ICMR1_BCWP) | ||
74 | |||
75 | #define ICMR3_RDRFS 0x20 | ||
76 | #define ICMR3_ACKWP 0x10 | ||
77 | #define ICMR3_ACKBT 0x08 | ||
78 | |||
79 | #define ICIER_TIE 0x80 | ||
80 | #define ICIER_TEIE 0x40 | ||
81 | #define ICIER_RIE 0x20 | ||
82 | #define ICIER_NAKIE 0x10 | ||
83 | |||
84 | #define ICSR2_NACKF 0x10 | ||
85 | |||
86 | /* ICBRx (@ PCLK 33MHz) */ | ||
87 | #define ICBR_RESERVED 0xe0 /* Should be 1 on writes */ | ||
88 | #define ICBRL_SP100K (19 | ICBR_RESERVED) | ||
89 | #define ICBRH_SP100K (16 | ICBR_RESERVED) | ||
90 | #define ICBRL_SP400K (21 | ICBR_RESERVED) | ||
91 | #define ICBRH_SP400K (9 | ICBR_RESERVED) | ||
92 | |||
93 | #define RIIC_INIT_MSG -1 | ||
94 | |||
95 | struct riic_dev { | ||
96 | void __iomem *base; | ||
97 | u8 *buf; | ||
98 | struct i2c_msg *msg; | ||
99 | int bytes_left; | ||
100 | int err; | ||
101 | int is_last; | ||
102 | struct completion msg_done; | ||
103 | struct i2c_adapter adapter; | ||
104 | struct clk *clk; | ||
105 | }; | ||
106 | |||
107 | struct riic_irq_desc { | ||
108 | int res_num; | ||
109 | irq_handler_t isr; | ||
110 | char *name; | ||
111 | }; | ||
112 | |||
113 | static inline void riic_clear_set_bit(struct riic_dev *riic, u8 clear, u8 set, u8 reg) | ||
114 | { | ||
115 | writeb((readb(riic->base + reg) & ~clear) | set, riic->base + reg); | ||
116 | } | ||
117 | |||
118 | static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) | ||
119 | { | ||
120 | struct riic_dev *riic = i2c_get_adapdata(adap); | ||
121 | unsigned long time_left; | ||
122 | int i, ret; | ||
123 | u8 start_bit; | ||
124 | |||
125 | ret = clk_prepare_enable(riic->clk); | ||
126 | if (ret) | ||
127 | return ret; | ||
128 | |||
129 | if (readb(riic->base + RIIC_ICCR2) & ICCR2_BBSY) { | ||
130 | riic->err = -EBUSY; | ||
131 | goto out; | ||
132 | } | ||
133 | |||
134 | reinit_completion(&riic->msg_done); | ||
135 | riic->err = 0; | ||
136 | |||
137 | writeb(0, riic->base + RIIC_ICSR2); | ||
138 | |||
139 | for (i = 0, start_bit = ICCR2_ST; i < num; i++) { | ||
140 | riic->bytes_left = RIIC_INIT_MSG; | ||
141 | riic->buf = msgs[i].buf; | ||
142 | riic->msg = &msgs[i]; | ||
143 | riic->is_last = (i == num - 1); | ||
144 | |||
145 | writeb(ICIER_NAKIE | ICIER_TIE, riic->base + RIIC_ICIER); | ||
146 | |||
147 | writeb(start_bit, riic->base + RIIC_ICCR2); | ||
148 | |||
149 | time_left = wait_for_completion_timeout(&riic->msg_done, riic->adapter.timeout); | ||
150 | if (time_left == 0) | ||
151 | riic->err = -ETIMEDOUT; | ||
152 | |||
153 | if (riic->err) | ||
154 | break; | ||
155 | |||
156 | start_bit = ICCR2_RS; | ||
157 | } | ||
158 | |||
159 | out: | ||
160 | clk_disable_unprepare(riic->clk); | ||
161 | |||
162 | return riic->err ?: num; | ||
163 | } | ||
164 | |||
165 | static irqreturn_t riic_tdre_isr(int irq, void *data) | ||
166 | { | ||
167 | struct riic_dev *riic = data; | ||
168 | u8 val; | ||
169 | |||
170 | if (!riic->bytes_left) | ||
171 | return IRQ_NONE; | ||
172 | |||
173 | if (riic->bytes_left == RIIC_INIT_MSG) { | ||
174 | val = !!(riic->msg->flags & I2C_M_RD); | ||
175 | if (val) | ||
176 | /* On read, switch over to receive interrupt */ | ||
177 | riic_clear_set_bit(riic, ICIER_TIE, ICIER_RIE, RIIC_ICIER); | ||
178 | else | ||
179 | /* On write, initialize length */ | ||
180 | riic->bytes_left = riic->msg->len; | ||
181 | |||
182 | val |= (riic->msg->addr << 1); | ||
183 | } else { | ||
184 | val = *riic->buf; | ||
185 | riic->buf++; | ||
186 | riic->bytes_left--; | ||
187 | } | ||
188 | |||
189 | /* | ||
190 | * Switch to transmission ended interrupt when done. Do check here | ||
191 | * after bytes_left was initialized to support SMBUS_QUICK (new msg has | ||
192 | * 0 length then) | ||
193 | */ | ||
194 | if (riic->bytes_left == 0) | ||
195 | riic_clear_set_bit(riic, ICIER_TIE, ICIER_TEIE, RIIC_ICIER); | ||
196 | |||
197 | /* | ||
198 | * This acks the TIE interrupt. We get another TIE immediately if our | ||
199 | * value could be moved to the shadow shift register right away. So | ||
200 | * this must be after updates to ICIER (where we want to disable TIE)! | ||
201 | */ | ||
202 | writeb(val, riic->base + RIIC_ICDRT); | ||
203 | |||
204 | return IRQ_HANDLED; | ||
205 | } | ||
206 | |||
207 | static irqreturn_t riic_tend_isr(int irq, void *data) | ||
208 | { | ||
209 | struct riic_dev *riic = data; | ||
210 | |||
211 | if (readb(riic->base + RIIC_ICSR2) & ICSR2_NACKF) { | ||
212 | /* We got a NACKIE */ | ||
213 | readb(riic->base + RIIC_ICDRR); /* dummy read */ | ||
214 | riic->err = -ENXIO; | ||
215 | } else if (riic->bytes_left) { | ||
216 | return IRQ_NONE; | ||
217 | } | ||
218 | |||
219 | if (riic->is_last || riic->err) | ||
220 | writeb(ICCR2_SP, riic->base + RIIC_ICCR2); | ||
221 | |||
222 | writeb(0, riic->base + RIIC_ICIER); | ||
223 | complete(&riic->msg_done); | ||
224 | |||
225 | return IRQ_HANDLED; | ||
226 | } | ||
227 | |||
228 | static irqreturn_t riic_rdrf_isr(int irq, void *data) | ||
229 | { | ||
230 | struct riic_dev *riic = data; | ||
231 | |||
232 | if (!riic->bytes_left) | ||
233 | return IRQ_NONE; | ||
234 | |||
235 | if (riic->bytes_left == RIIC_INIT_MSG) { | ||
236 | riic->bytes_left = riic->msg->len; | ||
237 | readb(riic->base + RIIC_ICDRR); /* dummy read */ | ||
238 | return IRQ_HANDLED; | ||
239 | } | ||
240 | |||
241 | if (riic->bytes_left == 1) { | ||
242 | /* STOP must come before we set ACKBT! */ | ||
243 | if (riic->is_last) | ||
244 | writeb(ICCR2_SP, riic->base + RIIC_ICCR2); | ||
245 | |||
246 | riic_clear_set_bit(riic, 0, ICMR3_ACKBT, RIIC_ICMR3); | ||
247 | |||
248 | writeb(0, riic->base + RIIC_ICIER); | ||
249 | complete(&riic->msg_done); | ||
250 | } else { | ||
251 | riic_clear_set_bit(riic, ICMR3_ACKBT, 0, RIIC_ICMR3); | ||
252 | } | ||
253 | |||
254 | /* Reading acks the RIE interrupt */ | ||
255 | *riic->buf = readb(riic->base + RIIC_ICDRR); | ||
256 | riic->buf++; | ||
257 | riic->bytes_left--; | ||
258 | |||
259 | return IRQ_HANDLED; | ||
260 | } | ||
261 | |||
262 | static u32 riic_func(struct i2c_adapter *adap) | ||
263 | { | ||
264 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; | ||
265 | } | ||
266 | |||
267 | static const struct i2c_algorithm riic_algo = { | ||
268 | .master_xfer = riic_xfer, | ||
269 | .functionality = riic_func, | ||
270 | }; | ||
271 | |||
272 | static int riic_init_hw(struct riic_dev *riic, u32 spd) | ||
273 | { | ||
274 | int ret; | ||
275 | unsigned long rate; | ||
276 | |||
277 | ret = clk_prepare_enable(riic->clk); | ||
278 | if (ret) | ||
279 | return ret; | ||
280 | |||
281 | /* | ||
282 | * TODO: Implement formula to calculate the timing values depending on | ||
283 | * variable parent clock rate and arbitrary bus speed | ||
284 | */ | ||
285 | rate = clk_get_rate(riic->clk); | ||
286 | if (rate != 33325000) { | ||
287 | dev_err(&riic->adapter.dev, | ||
288 | "invalid parent clk (%lu). Must be 33325000Hz\n", rate); | ||
289 | clk_disable_unprepare(riic->clk); | ||
290 | return -EINVAL; | ||
291 | } | ||
292 | |||
293 | /* Changing the order of accessing IICRST and ICE may break things! */ | ||
294 | writeb(ICCR1_IICRST | ICCR1_SOWP, riic->base + RIIC_ICCR1); | ||
295 | riic_clear_set_bit(riic, 0, ICCR1_ICE, RIIC_ICCR1); | ||
296 | |||
297 | switch (spd) { | ||
298 | case 100000: | ||
299 | writeb(ICMR1_CKS(3), riic->base + RIIC_ICMR1); | ||
300 | writeb(ICBRH_SP100K, riic->base + RIIC_ICBRH); | ||
301 | writeb(ICBRL_SP100K, riic->base + RIIC_ICBRL); | ||
302 | break; | ||
303 | case 400000: | ||
304 | writeb(ICMR1_CKS(1), riic->base + RIIC_ICMR1); | ||
305 | writeb(ICBRH_SP400K, riic->base + RIIC_ICBRH); | ||
306 | writeb(ICBRL_SP400K, riic->base + RIIC_ICBRL); | ||
307 | break; | ||
308 | default: | ||
309 | dev_err(&riic->adapter.dev, | ||
310 | "unsupported bus speed (%dHz). Use 100000 or 400000\n", spd); | ||
311 | clk_disable_unprepare(riic->clk); | ||
312 | return -EINVAL; | ||
313 | } | ||
314 | |||
315 | writeb(0, riic->base + RIIC_ICSER); | ||
316 | writeb(ICMR3_ACKWP | ICMR3_RDRFS, riic->base + RIIC_ICMR3); | ||
317 | |||
318 | riic_clear_set_bit(riic, ICCR1_IICRST, 0, RIIC_ICCR1); | ||
319 | |||
320 | clk_disable_unprepare(riic->clk); | ||
321 | |||
322 | return 0; | ||
323 | } | ||
324 | |||
325 | static struct riic_irq_desc riic_irqs[] = { | ||
326 | { .res_num = 0, .isr = riic_tend_isr, .name = "riic-tend" }, | ||
327 | { .res_num = 1, .isr = riic_rdrf_isr, .name = "riic-rdrf" }, | ||
328 | { .res_num = 2, .isr = riic_tdre_isr, .name = "riic-tdre" }, | ||
329 | { .res_num = 5, .isr = riic_tend_isr, .name = "riic-nack" }, | ||
330 | }; | ||
331 | |||
332 | static int riic_i2c_probe(struct platform_device *pdev) | ||
333 | { | ||
334 | struct device_node *np = pdev->dev.of_node; | ||
335 | struct riic_dev *riic; | ||
336 | struct i2c_adapter *adap; | ||
337 | struct resource *res; | ||
338 | u32 bus_rate = 0; | ||
339 | int i, ret; | ||
340 | |||
341 | riic = devm_kzalloc(&pdev->dev, sizeof(*riic), GFP_KERNEL); | ||
342 | if (!riic) | ||
343 | return -ENOMEM; | ||
344 | |||
345 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
346 | riic->base = devm_ioremap_resource(&pdev->dev, res); | ||
347 | if (IS_ERR(riic->base)) | ||
348 | return PTR_ERR(riic->base); | ||
349 | |||
350 | riic->clk = devm_clk_get(&pdev->dev, NULL); | ||
351 | if (IS_ERR(riic->clk)) { | ||
352 | dev_err(&pdev->dev, "missing controller clock"); | ||
353 | return PTR_ERR(riic->clk); | ||
354 | } | ||
355 | |||
356 | for (i = 0; i < ARRAY_SIZE(riic_irqs); i++) { | ||
357 | res = platform_get_resource(pdev, IORESOURCE_IRQ, riic_irqs[i].res_num); | ||
358 | if (!res) | ||
359 | return -ENODEV; | ||
360 | |||
361 | ret = devm_request_irq(&pdev->dev, res->start, riic_irqs[i].isr, | ||
362 | 0, riic_irqs[i].name, riic); | ||
363 | if (ret) { | ||
364 | dev_err(&pdev->dev, "failed to request irq %s\n", riic_irqs[i].name); | ||
365 | return ret; | ||
366 | } | ||
367 | } | ||
368 | |||
369 | adap = &riic->adapter; | ||
370 | i2c_set_adapdata(adap, riic); | ||
371 | strlcpy(adap->name, "Renesas RIIC adapter", sizeof(adap->name)); | ||
372 | adap->owner = THIS_MODULE; | ||
373 | adap->algo = &riic_algo; | ||
374 | adap->dev.parent = &pdev->dev; | ||
375 | adap->dev.of_node = pdev->dev.of_node; | ||
376 | |||
377 | init_completion(&riic->msg_done); | ||
378 | |||
379 | of_property_read_u32(np, "clock-frequency", &bus_rate); | ||
380 | ret = riic_init_hw(riic, bus_rate); | ||
381 | if (ret) | ||
382 | return ret; | ||
383 | |||
384 | |||
385 | ret = i2c_add_adapter(adap); | ||
386 | if (ret) { | ||
387 | dev_err(&pdev->dev, "failed to add adapter\n"); | ||
388 | return ret; | ||
389 | } | ||
390 | |||
391 | platform_set_drvdata(pdev, riic); | ||
392 | |||
393 | dev_info(&pdev->dev, "registered with %dHz bus speed\n", bus_rate); | ||
394 | return 0; | ||
395 | } | ||
396 | |||
397 | static int riic_i2c_remove(struct platform_device *pdev) | ||
398 | { | ||
399 | struct riic_dev *riic = platform_get_drvdata(pdev); | ||
400 | |||
401 | writeb(0, riic->base + RIIC_ICIER); | ||
402 | i2c_del_adapter(&riic->adapter); | ||
403 | |||
404 | return 0; | ||
405 | } | ||
406 | |||
407 | static struct of_device_id riic_i2c_dt_ids[] = { | ||
408 | { .compatible = "renesas,riic-rz" }, | ||
409 | { /* Sentinel */ }, | ||
410 | }; | ||
411 | |||
412 | static struct platform_driver riic_i2c_driver = { | ||
413 | .probe = riic_i2c_probe, | ||
414 | .remove = riic_i2c_remove, | ||
415 | .driver = { | ||
416 | .name = "i2c-riic", | ||
417 | .owner = THIS_MODULE, | ||
418 | .of_match_table = riic_i2c_dt_ids, | ||
419 | }, | ||
420 | }; | ||
421 | |||
422 | module_platform_driver(riic_i2c_driver); | ||
423 | |||
424 | MODULE_DESCRIPTION("Renesas RIIC adapter"); | ||
425 | MODULE_AUTHOR("Wolfram Sang <wsa@sang-engineering.com>"); | ||
426 | MODULE_LICENSE("GPL v2"); | ||
427 | MODULE_DEVICE_TABLE(of, riic_i2c_dt_ids); | ||
diff --git a/drivers/i2c/busses/i2c-robotfuzz-osif.c b/drivers/i2c/busses/i2c-robotfuzz-osif.c new file mode 100644 index 000000000000..ced9c6a308d1 --- /dev/null +++ b/drivers/i2c/busses/i2c-robotfuzz-osif.c | |||
@@ -0,0 +1,202 @@ | |||
1 | /* | ||
2 | * Driver for RobotFuzz OSIF | ||
3 | * | ||
4 | * Copyright (c) 2013 Andrew Lunn <andrew@lunn.ch> | ||
5 | * Copyright (c) 2007 Barry Carter <Barry.Carter@robotfuzz.com> | ||
6 | * | ||
7 | * Based on the i2c-tiny-usb by | ||
8 | * | ||
9 | * Copyright (C) 2006 Til Harbaum (Till@Harbaum.org) | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public License as | ||
13 | * published by the Free Software Foundation, version 2. | ||
14 | */ | ||
15 | |||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/errno.h> | ||
19 | #include <linux/i2c.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/usb.h> | ||
22 | |||
23 | #define OSIFI2C_READ 20 | ||
24 | #define OSIFI2C_WRITE 21 | ||
25 | #define OSIFI2C_STOP 22 | ||
26 | #define OSIFI2C_STATUS 23 | ||
27 | #define OSIFI2C_SET_BIT_RATE 24 | ||
28 | |||
29 | #define STATUS_ADDRESS_ACK 0 | ||
30 | #define STATUS_ADDRESS_NAK 2 | ||
31 | |||
32 | struct osif_priv { | ||
33 | struct usb_device *usb_dev; | ||
34 | struct usb_interface *interface; | ||
35 | struct i2c_adapter adapter; | ||
36 | unsigned char status; | ||
37 | }; | ||
38 | |||
39 | static int osif_usb_read(struct i2c_adapter *adapter, int cmd, | ||
40 | int value, int index, void *data, int len) | ||
41 | { | ||
42 | struct osif_priv *priv = adapter->algo_data; | ||
43 | |||
44 | return usb_control_msg(priv->usb_dev, usb_rcvctrlpipe(priv->usb_dev, 0), | ||
45 | cmd, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | | ||
46 | USB_DIR_IN, value, index, data, len, 2000); | ||
47 | } | ||
48 | |||
49 | static int osif_usb_write(struct i2c_adapter *adapter, int cmd, | ||
50 | int value, int index, void *data, int len) | ||
51 | { | ||
52 | |||
53 | struct osif_priv *priv = adapter->algo_data; | ||
54 | |||
55 | return usb_control_msg(priv->usb_dev, usb_sndctrlpipe(priv->usb_dev, 0), | ||
56 | cmd, USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
57 | value, index, data, len, 2000); | ||
58 | } | ||
59 | |||
60 | static int osif_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, | ||
61 | int num) | ||
62 | { | ||
63 | struct osif_priv *priv = adapter->algo_data; | ||
64 | struct i2c_msg *pmsg; | ||
65 | int ret = 0; | ||
66 | int i, cmd; | ||
67 | |||
68 | for (i = 0; ret >= 0 && i < num; i++) { | ||
69 | pmsg = &msgs[i]; | ||
70 | |||
71 | if (pmsg->flags & I2C_M_RD) { | ||
72 | cmd = OSIFI2C_READ; | ||
73 | |||
74 | ret = osif_usb_read(adapter, cmd, pmsg->flags, | ||
75 | pmsg->addr, pmsg->buf, | ||
76 | pmsg->len); | ||
77 | if (ret != pmsg->len) { | ||
78 | dev_err(&adapter->dev, "failure reading data\n"); | ||
79 | return -EREMOTEIO; | ||
80 | } | ||
81 | } else { | ||
82 | cmd = OSIFI2C_WRITE; | ||
83 | |||
84 | ret = osif_usb_write(adapter, cmd, pmsg->flags, | ||
85 | pmsg->addr, pmsg->buf, pmsg->len); | ||
86 | if (ret != pmsg->len) { | ||
87 | dev_err(&adapter->dev, "failure writing data\n"); | ||
88 | return -EREMOTEIO; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | ret = osif_usb_read(adapter, OSIFI2C_STOP, 0, 0, NULL, 0); | ||
93 | if (ret) { | ||
94 | dev_err(&adapter->dev, "failure sending STOP\n"); | ||
95 | return -EREMOTEIO; | ||
96 | } | ||
97 | |||
98 | /* read status */ | ||
99 | ret = osif_usb_read(adapter, OSIFI2C_STATUS, 0, 0, | ||
100 | &priv->status, 1); | ||
101 | if (ret != 1) { | ||
102 | dev_err(&adapter->dev, "failure reading status\n"); | ||
103 | return -EREMOTEIO; | ||
104 | } | ||
105 | |||
106 | if (priv->status != STATUS_ADDRESS_ACK) { | ||
107 | dev_dbg(&adapter->dev, "status = %d\n", priv->status); | ||
108 | return -EREMOTEIO; | ||
109 | } | ||
110 | } | ||
111 | |||
112 | return i; | ||
113 | } | ||
114 | |||
115 | static u32 osif_func(struct i2c_adapter *adapter) | ||
116 | { | ||
117 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; | ||
118 | } | ||
119 | |||
120 | static struct i2c_algorithm osif_algorithm = { | ||
121 | .master_xfer = osif_xfer, | ||
122 | .functionality = osif_func, | ||
123 | }; | ||
124 | |||
125 | #define USB_OSIF_VENDOR_ID 0x1964 | ||
126 | #define USB_OSIF_PRODUCT_ID 0x0001 | ||
127 | |||
128 | static struct usb_device_id osif_table[] = { | ||
129 | { USB_DEVICE(USB_OSIF_VENDOR_ID, USB_OSIF_PRODUCT_ID) }, | ||
130 | { } | ||
131 | }; | ||
132 | MODULE_DEVICE_TABLE(usb, osif_table); | ||
133 | |||
134 | static int osif_probe(struct usb_interface *interface, | ||
135 | const struct usb_device_id *id) | ||
136 | { | ||
137 | int ret; | ||
138 | struct osif_priv *priv; | ||
139 | u16 version; | ||
140 | |||
141 | priv = devm_kzalloc(&interface->dev, sizeof(*priv), GFP_KERNEL); | ||
142 | if (!priv) | ||
143 | return -ENOMEM; | ||
144 | |||
145 | priv->usb_dev = usb_get_dev(interface_to_usbdev(interface)); | ||
146 | priv->interface = interface; | ||
147 | |||
148 | usb_set_intfdata(interface, priv); | ||
149 | |||
150 | priv->adapter.owner = THIS_MODULE; | ||
151 | priv->adapter.class = I2C_CLASS_HWMON; | ||
152 | priv->adapter.algo = &osif_algorithm; | ||
153 | priv->adapter.algo_data = priv; | ||
154 | snprintf(priv->adapter.name, sizeof(priv->adapter.name), | ||
155 | "OSIF at bus %03d device %03d", | ||
156 | priv->usb_dev->bus->busnum, priv->usb_dev->devnum); | ||
157 | |||
158 | /* | ||
159 | * Set bus frequency. The frequency is: | ||
160 | * 120,000,000 / ( 16 + 2 * div * 4^prescale). | ||
161 | * Using dev = 52, prescale = 0 give 100KHz */ | ||
162 | ret = osif_usb_read(&priv->adapter, OSIFI2C_SET_BIT_RATE, 52, 0, | ||
163 | NULL, 0); | ||
164 | if (ret) { | ||
165 | dev_err(&interface->dev, "failure sending bit rate"); | ||
166 | usb_put_dev(priv->usb_dev); | ||
167 | return ret; | ||
168 | } | ||
169 | |||
170 | i2c_add_adapter(&(priv->adapter)); | ||
171 | |||
172 | version = le16_to_cpu(priv->usb_dev->descriptor.bcdDevice); | ||
173 | dev_info(&interface->dev, | ||
174 | "version %x.%02x found at bus %03d address %03d", | ||
175 | version >> 8, version & 0xff, | ||
176 | priv->usb_dev->bus->busnum, priv->usb_dev->devnum); | ||
177 | |||
178 | return 0; | ||
179 | } | ||
180 | |||
181 | static void osif_disconnect(struct usb_interface *interface) | ||
182 | { | ||
183 | struct osif_priv *priv = usb_get_intfdata(interface); | ||
184 | |||
185 | i2c_del_adapter(&(priv->adapter)); | ||
186 | usb_set_intfdata(interface, NULL); | ||
187 | usb_put_dev(priv->usb_dev); | ||
188 | } | ||
189 | |||
190 | static struct usb_driver osif_driver = { | ||
191 | .name = "RobotFuzz Open Source InterFace, OSIF", | ||
192 | .probe = osif_probe, | ||
193 | .disconnect = osif_disconnect, | ||
194 | .id_table = osif_table, | ||
195 | }; | ||
196 | |||
197 | module_usb_driver(osif_driver); | ||
198 | |||
199 | MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>"); | ||
200 | MODULE_AUTHOR("Barry Carter <barry.carter@robotfuzz.com>"); | ||
201 | MODULE_DESCRIPTION("RobotFuzz OSIF driver"); | ||
202 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index bf8fb94ebc5d..684d21e71e4a 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -86,6 +86,7 @@ | |||
86 | #define QUIRK_S3C2440 (1 << 0) | 86 | #define QUIRK_S3C2440 (1 << 0) |
87 | #define QUIRK_HDMIPHY (1 << 1) | 87 | #define QUIRK_HDMIPHY (1 << 1) |
88 | #define QUIRK_NO_GPIO (1 << 2) | 88 | #define QUIRK_NO_GPIO (1 << 2) |
89 | #define QUIRK_POLL (1 << 3) | ||
89 | 90 | ||
90 | /* Max time to wait for bus to become idle after a xfer (in us) */ | 91 | /* Max time to wait for bus to become idle after a xfer (in us) */ |
91 | #define S3C2410_IDLE_TIMEOUT 5000 | 92 | #define S3C2410_IDLE_TIMEOUT 5000 |
@@ -101,7 +102,7 @@ enum s3c24xx_i2c_state { | |||
101 | 102 | ||
102 | struct s3c24xx_i2c { | 103 | struct s3c24xx_i2c { |
103 | wait_queue_head_t wait; | 104 | wait_queue_head_t wait; |
104 | unsigned int quirks; | 105 | kernel_ulong_t quirks; |
105 | unsigned int suspended:1; | 106 | unsigned int suspended:1; |
106 | 107 | ||
107 | struct i2c_msg *msg; | 108 | struct i2c_msg *msg; |
@@ -123,7 +124,7 @@ struct s3c24xx_i2c { | |||
123 | struct s3c2410_platform_i2c *pdata; | 124 | struct s3c2410_platform_i2c *pdata; |
124 | int gpios[2]; | 125 | int gpios[2]; |
125 | struct pinctrl *pctrl; | 126 | struct pinctrl *pctrl; |
126 | #ifdef CONFIG_CPU_FREQ | 127 | #if defined(CONFIG_ARM_S3C24XX_CPUFREQ) |
127 | struct notifier_block freq_transition; | 128 | struct notifier_block freq_transition; |
128 | #endif | 129 | #endif |
129 | }; | 130 | }; |
@@ -142,6 +143,8 @@ static struct platform_device_id s3c24xx_driver_ids[] = { | |||
142 | }; | 143 | }; |
143 | MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids); | 144 | MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids); |
144 | 145 | ||
146 | static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat); | ||
147 | |||
145 | #ifdef CONFIG_OF | 148 | #ifdef CONFIG_OF |
146 | static const struct of_device_id s3c24xx_i2c_match[] = { | 149 | static const struct of_device_id s3c24xx_i2c_match[] = { |
147 | { .compatible = "samsung,s3c2410-i2c", .data = (void *)0 }, | 150 | { .compatible = "samsung,s3c2410-i2c", .data = (void *)0 }, |
@@ -150,6 +153,8 @@ static const struct of_device_id s3c24xx_i2c_match[] = { | |||
150 | .data = (void *)(QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO) }, | 153 | .data = (void *)(QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO) }, |
151 | { .compatible = "samsung,exynos5440-i2c", | 154 | { .compatible = "samsung,exynos5440-i2c", |
152 | .data = (void *)(QUIRK_S3C2440 | QUIRK_NO_GPIO) }, | 155 | .data = (void *)(QUIRK_S3C2440 | QUIRK_NO_GPIO) }, |
156 | { .compatible = "samsung,exynos5-sata-phy-i2c", | ||
157 | .data = (void *)(QUIRK_S3C2440 | QUIRK_POLL | QUIRK_NO_GPIO) }, | ||
153 | {}, | 158 | {}, |
154 | }; | 159 | }; |
155 | MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match); | 160 | MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match); |
@@ -160,12 +165,12 @@ MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match); | |||
160 | * Get controller type either from device tree or platform device variant. | 165 | * Get controller type either from device tree or platform device variant. |
161 | */ | 166 | */ |
162 | 167 | ||
163 | static inline unsigned int s3c24xx_get_device_quirks(struct platform_device *pdev) | 168 | static inline kernel_ulong_t s3c24xx_get_device_quirks(struct platform_device *pdev) |
164 | { | 169 | { |
165 | if (pdev->dev.of_node) { | 170 | if (pdev->dev.of_node) { |
166 | const struct of_device_id *match; | 171 | const struct of_device_id *match; |
167 | match = of_match_node(s3c24xx_i2c_match, pdev->dev.of_node); | 172 | match = of_match_node(s3c24xx_i2c_match, pdev->dev.of_node); |
168 | return (unsigned int)match->data; | 173 | return (kernel_ulong_t)match->data; |
169 | } | 174 | } |
170 | 175 | ||
171 | return platform_get_device_id(pdev)->driver_data; | 176 | return platform_get_device_id(pdev)->driver_data; |
@@ -188,7 +193,8 @@ static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret) | |||
188 | if (ret) | 193 | if (ret) |
189 | i2c->msg_idx = ret; | 194 | i2c->msg_idx = ret; |
190 | 195 | ||
191 | wake_up(&i2c->wait); | 196 | if (!(i2c->quirks & QUIRK_POLL)) |
197 | wake_up(&i2c->wait); | ||
192 | } | 198 | } |
193 | 199 | ||
194 | static inline void s3c24xx_i2c_disable_ack(struct s3c24xx_i2c *i2c) | 200 | static inline void s3c24xx_i2c_disable_ack(struct s3c24xx_i2c *i2c) |
@@ -225,6 +231,22 @@ static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c) | |||
225 | writel(tmp | S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON); | 231 | writel(tmp | S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON); |
226 | } | 232 | } |
227 | 233 | ||
234 | static bool is_ack(struct s3c24xx_i2c *i2c) | ||
235 | { | ||
236 | int tries; | ||
237 | |||
238 | for (tries = 50; tries; --tries) { | ||
239 | if (readl(i2c->regs + S3C2410_IICCON) | ||
240 | & S3C2410_IICCON_IRQPEND) { | ||
241 | if (!(readl(i2c->regs + S3C2410_IICSTAT) | ||
242 | & S3C2410_IICSTAT_LASTBIT)) | ||
243 | return true; | ||
244 | } | ||
245 | usleep_range(1000, 2000); | ||
246 | } | ||
247 | dev_err(i2c->dev, "ack was not recieved\n"); | ||
248 | return false; | ||
249 | } | ||
228 | 250 | ||
229 | /* s3c24xx_i2c_message_start | 251 | /* s3c24xx_i2c_message_start |
230 | * | 252 | * |
@@ -269,6 +291,16 @@ static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c, | |||
269 | 291 | ||
270 | stat |= S3C2410_IICSTAT_START; | 292 | stat |= S3C2410_IICSTAT_START; |
271 | writel(stat, i2c->regs + S3C2410_IICSTAT); | 293 | writel(stat, i2c->regs + S3C2410_IICSTAT); |
294 | |||
295 | if (i2c->quirks & QUIRK_POLL) { | ||
296 | while ((i2c->msg_num != 0) && is_ack(i2c)) { | ||
297 | i2c_s3c_irq_nextbyte(i2c, stat); | ||
298 | stat = readl(i2c->regs + S3C2410_IICSTAT); | ||
299 | |||
300 | if (stat & S3C2410_IICSTAT_ARBITR) | ||
301 | dev_err(i2c->dev, "deal with arbitration loss\n"); | ||
302 | } | ||
303 | } | ||
272 | } | 304 | } |
273 | 305 | ||
274 | static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret) | 306 | static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret) |
@@ -676,6 +708,15 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, | |||
676 | s3c24xx_i2c_enable_irq(i2c); | 708 | s3c24xx_i2c_enable_irq(i2c); |
677 | s3c24xx_i2c_message_start(i2c, msgs); | 709 | s3c24xx_i2c_message_start(i2c, msgs); |
678 | 710 | ||
711 | if (i2c->quirks & QUIRK_POLL) { | ||
712 | ret = i2c->msg_idx; | ||
713 | |||
714 | if (ret != num) | ||
715 | dev_dbg(i2c->dev, "incomplete xfer (%d)\n", ret); | ||
716 | |||
717 | goto out; | ||
718 | } | ||
719 | |||
679 | timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5); | 720 | timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5); |
680 | 721 | ||
681 | ret = i2c->msg_idx; | 722 | ret = i2c->msg_idx; |
@@ -821,6 +862,9 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got) | |||
821 | if (div1 == 512) | 862 | if (div1 == 512) |
822 | iiccon |= S3C2410_IICCON_TXDIV_512; | 863 | iiccon |= S3C2410_IICCON_TXDIV_512; |
823 | 864 | ||
865 | if (i2c->quirks & QUIRK_POLL) | ||
866 | iiccon |= S3C2410_IICCON_SCALE(2); | ||
867 | |||
824 | writel(iiccon, i2c->regs + S3C2410_IICCON); | 868 | writel(iiccon, i2c->regs + S3C2410_IICCON); |
825 | 869 | ||
826 | if (i2c->quirks & QUIRK_S3C2440) { | 870 | if (i2c->quirks & QUIRK_S3C2440) { |
@@ -843,7 +887,7 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got) | |||
843 | return 0; | 887 | return 0; |
844 | } | 888 | } |
845 | 889 | ||
846 | #ifdef CONFIG_CPU_FREQ | 890 | #if defined(CONFIG_ARM_S3C24XX_CPUFREQ) |
847 | 891 | ||
848 | #define freq_to_i2c(_n) container_of(_n, struct s3c24xx_i2c, freq_transition) | 892 | #define freq_to_i2c(_n) container_of(_n, struct s3c24xx_i2c, freq_transition) |
849 | 893 | ||
@@ -1118,18 +1162,20 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1118 | * ensure no current IRQs pending | 1162 | * ensure no current IRQs pending |
1119 | */ | 1163 | */ |
1120 | 1164 | ||
1121 | i2c->irq = ret = platform_get_irq(pdev, 0); | 1165 | if (!(i2c->quirks & QUIRK_POLL)) { |
1122 | if (ret <= 0) { | 1166 | i2c->irq = ret = platform_get_irq(pdev, 0); |
1123 | dev_err(&pdev->dev, "cannot find IRQ\n"); | 1167 | if (ret <= 0) { |
1124 | return ret; | 1168 | dev_err(&pdev->dev, "cannot find IRQ\n"); |
1125 | } | 1169 | return ret; |
1170 | } | ||
1126 | 1171 | ||
1127 | ret = devm_request_irq(&pdev->dev, i2c->irq, s3c24xx_i2c_irq, 0, | 1172 | ret = devm_request_irq(&pdev->dev, i2c->irq, s3c24xx_i2c_irq, 0, |
1128 | dev_name(&pdev->dev), i2c); | 1173 | dev_name(&pdev->dev), i2c); |
1129 | 1174 | ||
1130 | if (ret != 0) { | 1175 | if (ret != 0) { |
1131 | dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); | 1176 | dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); |
1132 | return ret; | 1177 | return ret; |
1178 | } | ||
1133 | } | 1179 | } |
1134 | 1180 | ||
1135 | ret = s3c24xx_i2c_register_cpufreq(i2c); | 1181 | ret = s3c24xx_i2c_register_cpufreq(i2c); |
diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c index e7d3b755af3b..0ed77eeff31e 100644 --- a/drivers/i2c/busses/i2c-tiny-usb.c +++ b/drivers/i2c/busses/i2c-tiny-usb.c | |||
@@ -162,7 +162,6 @@ static const struct i2c_algorithm usb_algorithm = { | |||
162 | static const struct usb_device_id i2c_tiny_usb_table[] = { | 162 | static const struct usb_device_id i2c_tiny_usb_table[] = { |
163 | { USB_DEVICE(0x0403, 0xc631) }, /* FTDI */ | 163 | { USB_DEVICE(0x0403, 0xc631) }, /* FTDI */ |
164 | { USB_DEVICE(0x1c40, 0x0534) }, /* EZPrototypes */ | 164 | { USB_DEVICE(0x1c40, 0x0534) }, /* EZPrototypes */ |
165 | { USB_DEVICE(0x1964, 0x0001) }, /* Robofuzz OSIF */ | ||
166 | { } /* Terminating entry */ | 165 | { } /* Terminating entry */ |
167 | }; | 166 | }; |
168 | 167 | ||
diff --git a/drivers/i2c/busses/i2c-viperboard.c b/drivers/i2c/busses/i2c-viperboard.c index c68450cd8d5f..7533fa34d737 100644 --- a/drivers/i2c/busses/i2c-viperboard.c +++ b/drivers/i2c/busses/i2c-viperboard.c | |||
@@ -118,8 +118,7 @@ static int vprbrd_i2c_addr(struct usb_device *usb_dev, | |||
118 | static int vprbrd_i2c_read(struct vprbrd *vb, struct i2c_msg *msg) | 118 | static int vprbrd_i2c_read(struct vprbrd *vb, struct i2c_msg *msg) |
119 | { | 119 | { |
120 | int ret; | 120 | int ret; |
121 | u16 remain_len, bytes_xfer, len1, len2, | 121 | u16 remain_len, len1, len2, start = 0x0000; |
122 | start = 0x0000; | ||
123 | struct vprbrd_i2c_read_msg *rmsg = | 122 | struct vprbrd_i2c_read_msg *rmsg = |
124 | (struct vprbrd_i2c_read_msg *)vb->buf; | 123 | (struct vprbrd_i2c_read_msg *)vb->buf; |
125 | 124 | ||
@@ -166,7 +165,6 @@ static int vprbrd_i2c_read(struct vprbrd *vb, struct i2c_msg *msg) | |||
166 | rmsg->header.len3 = remain_len - 512; | 165 | rmsg->header.len3 = remain_len - 512; |
167 | rmsg->header.len4 = 0x00; | 166 | rmsg->header.len4 = 0x00; |
168 | rmsg->header.len5 = 0x00; | 167 | rmsg->header.len5 = 0x00; |
169 | bytes_xfer = remain_len; | ||
170 | remain_len = 0; | 168 | remain_len = 0; |
171 | } else if (remain_len <= 1022) { | 169 | } else if (remain_len <= 1022) { |
172 | len1 = 512; | 170 | len1 = 512; |
@@ -367,7 +365,7 @@ static int vprbrd_i2c_probe(struct platform_device *pdev) | |||
367 | int ret; | 365 | int ret; |
368 | int pipe; | 366 | int pipe; |
369 | 367 | ||
370 | vb_i2c = kzalloc(sizeof(*vb_i2c), GFP_KERNEL); | 368 | vb_i2c = devm_kzalloc(&pdev->dev, sizeof(*vb_i2c), GFP_KERNEL); |
371 | if (vb_i2c == NULL) | 369 | if (vb_i2c == NULL) |
372 | return -ENOMEM; | 370 | return -ENOMEM; |
373 | 371 | ||
@@ -394,14 +392,12 @@ static int vprbrd_i2c_probe(struct platform_device *pdev) | |||
394 | if (ret != 1) { | 392 | if (ret != 1) { |
395 | dev_err(&pdev->dev, | 393 | dev_err(&pdev->dev, |
396 | "failure setting i2c_bus_freq to %d\n", i2c_bus_freq); | 394 | "failure setting i2c_bus_freq to %d\n", i2c_bus_freq); |
397 | ret = -EIO; | 395 | return -EIO; |
398 | goto error; | ||
399 | } | 396 | } |
400 | } else { | 397 | } else { |
401 | dev_err(&pdev->dev, | 398 | dev_err(&pdev->dev, |
402 | "invalid i2c_bus_freq setting:%d\n", i2c_bus_freq); | 399 | "invalid i2c_bus_freq setting:%d\n", i2c_bus_freq); |
403 | ret = -EIO; | 400 | return -EIO; |
404 | goto error; | ||
405 | } | 401 | } |
406 | 402 | ||
407 | vb_i2c->i2c.dev.parent = &pdev->dev; | 403 | vb_i2c->i2c.dev.parent = &pdev->dev; |
@@ -412,10 +408,6 @@ static int vprbrd_i2c_probe(struct platform_device *pdev) | |||
412 | platform_set_drvdata(pdev, vb_i2c); | 408 | platform_set_drvdata(pdev, vb_i2c); |
413 | 409 | ||
414 | return 0; | 410 | return 0; |
415 | |||
416 | error: | ||
417 | kfree(vb_i2c); | ||
418 | return ret; | ||
419 | } | 411 | } |
420 | 412 | ||
421 | static int vprbrd_i2c_remove(struct platform_device *pdev) | 413 | static int vprbrd_i2c_remove(struct platform_device *pdev) |
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index fc2716afdfd9..6f9918f37b91 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/init.h> | 33 | #include <linux/init.h> |
34 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
35 | #include <linux/err.h> | ||
35 | #include <linux/delay.h> | 36 | #include <linux/delay.h> |
36 | #include <linux/platform_device.h> | 37 | #include <linux/platform_device.h> |
37 | #include <linux/i2c.h> | 38 | #include <linux/i2c.h> |
@@ -69,7 +70,7 @@ struct xiic_i2c { | |||
69 | struct i2c_adapter adap; | 70 | struct i2c_adapter adap; |
70 | struct i2c_msg *tx_msg; | 71 | struct i2c_msg *tx_msg; |
71 | spinlock_t lock; | 72 | spinlock_t lock; |
72 | unsigned int tx_pos; | 73 | unsigned int tx_pos; |
73 | unsigned int nmsgs; | 74 | unsigned int nmsgs; |
74 | enum xilinx_i2c_state state; | 75 | enum xilinx_i2c_state state; |
75 | struct i2c_msg *rx_msg; | 76 | struct i2c_msg *rx_msg; |
@@ -272,8 +273,8 @@ static void xiic_read_rx(struct xiic_i2c *i2c) | |||
272 | 273 | ||
273 | bytes_in_fifo = xiic_getreg8(i2c, XIIC_RFO_REG_OFFSET) + 1; | 274 | bytes_in_fifo = xiic_getreg8(i2c, XIIC_RFO_REG_OFFSET) + 1; |
274 | 275 | ||
275 | dev_dbg(i2c->adap.dev.parent, "%s entry, bytes in fifo: %d, msg: %d" | 276 | dev_dbg(i2c->adap.dev.parent, |
276 | ", SR: 0x%x, CR: 0x%x\n", | 277 | "%s entry, bytes in fifo: %d, msg: %d, SR: 0x%x, CR: 0x%x\n", |
277 | __func__, bytes_in_fifo, xiic_rx_space(i2c), | 278 | __func__, bytes_in_fifo, xiic_rx_space(i2c), |
278 | xiic_getreg8(i2c, XIIC_SR_REG_OFFSET), | 279 | xiic_getreg8(i2c, XIIC_SR_REG_OFFSET), |
279 | xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); | 280 | xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); |
@@ -340,9 +341,10 @@ static void xiic_process(struct xiic_i2c *i2c) | |||
340 | ier = xiic_getreg32(i2c, XIIC_IIER_OFFSET); | 341 | ier = xiic_getreg32(i2c, XIIC_IIER_OFFSET); |
341 | pend = isr & ier; | 342 | pend = isr & ier; |
342 | 343 | ||
343 | dev_dbg(i2c->adap.dev.parent, "%s entry, IER: 0x%x, ISR: 0x%x, " | 344 | dev_dbg(i2c->adap.dev.parent, "%s: IER: 0x%x, ISR: 0x%x, pend: 0x%x\n", |
344 | "pend: 0x%x, SR: 0x%x, msg: %p, nmsgs: %d\n", | 345 | __func__, ier, isr, pend); |
345 | __func__, ier, isr, pend, xiic_getreg8(i2c, XIIC_SR_REG_OFFSET), | 346 | dev_dbg(i2c->adap.dev.parent, "%s: SR: 0x%x, msg: %p, nmsgs: %d\n", |
347 | __func__, xiic_getreg8(i2c, XIIC_SR_REG_OFFSET), | ||
346 | i2c->tx_msg, i2c->nmsgs); | 348 | i2c->tx_msg, i2c->nmsgs); |
347 | 349 | ||
348 | /* Do not processes a devices interrupts if the device has no | 350 | /* Do not processes a devices interrupts if the device has no |
@@ -542,9 +544,10 @@ static void xiic_start_send(struct xiic_i2c *i2c) | |||
542 | 544 | ||
543 | xiic_irq_clr(i2c, XIIC_INTR_TX_ERROR_MASK); | 545 | xiic_irq_clr(i2c, XIIC_INTR_TX_ERROR_MASK); |
544 | 546 | ||
545 | dev_dbg(i2c->adap.dev.parent, "%s entry, msg: %p, len: %d, " | 547 | dev_dbg(i2c->adap.dev.parent, "%s entry, msg: %p, len: %d", |
546 | "ISR: 0x%x, CR: 0x%x\n", | 548 | __func__, msg, msg->len); |
547 | __func__, msg, msg->len, xiic_getreg32(i2c, XIIC_IISR_OFFSET), | 549 | dev_dbg(i2c->adap.dev.parent, "%s entry, ISR: 0x%x, CR: 0x%x\n", |
550 | __func__, xiic_getreg32(i2c, XIIC_IISR_OFFSET), | ||
548 | xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); | 551 | xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); |
549 | 552 | ||
550 | if (!(msg->flags & I2C_M_NOSTART)) { | 553 | if (!(msg->flags & I2C_M_NOSTART)) { |
@@ -695,33 +698,21 @@ static int xiic_i2c_probe(struct platform_device *pdev) | |||
695 | int ret, irq; | 698 | int ret, irq; |
696 | u8 i; | 699 | u8 i; |
697 | 700 | ||
701 | i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL); | ||
702 | if (!i2c) | ||
703 | return -ENOMEM; | ||
704 | |||
698 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 705 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
699 | if (!res) | 706 | i2c->base = devm_ioremap_resource(&pdev->dev, res); |
700 | goto resource_missing; | 707 | if (IS_ERR(i2c->base)) |
708 | return PTR_ERR(i2c->base); | ||
701 | 709 | ||
702 | irq = platform_get_irq(pdev, 0); | 710 | irq = platform_get_irq(pdev, 0); |
703 | if (irq < 0) | 711 | if (irq < 0) |
704 | goto resource_missing; | 712 | return irq; |
705 | 713 | ||
706 | pdata = dev_get_platdata(&pdev->dev); | 714 | pdata = dev_get_platdata(&pdev->dev); |
707 | 715 | ||
708 | i2c = kzalloc(sizeof(*i2c), GFP_KERNEL); | ||
709 | if (!i2c) | ||
710 | return -ENOMEM; | ||
711 | |||
712 | if (!request_mem_region(res->start, resource_size(res), pdev->name)) { | ||
713 | dev_err(&pdev->dev, "Memory region busy\n"); | ||
714 | ret = -EBUSY; | ||
715 | goto request_mem_failed; | ||
716 | } | ||
717 | |||
718 | i2c->base = ioremap(res->start, resource_size(res)); | ||
719 | if (!i2c->base) { | ||
720 | dev_err(&pdev->dev, "Unable to map registers\n"); | ||
721 | ret = -EIO; | ||
722 | goto map_failed; | ||
723 | } | ||
724 | |||
725 | /* hook up driver to tree */ | 716 | /* hook up driver to tree */ |
726 | platform_set_drvdata(pdev, i2c); | 717 | platform_set_drvdata(pdev, i2c); |
727 | i2c->adap = xiic_adapter; | 718 | i2c->adap = xiic_adapter; |
@@ -729,21 +720,23 @@ static int xiic_i2c_probe(struct platform_device *pdev) | |||
729 | i2c->adap.dev.parent = &pdev->dev; | 720 | i2c->adap.dev.parent = &pdev->dev; |
730 | i2c->adap.dev.of_node = pdev->dev.of_node; | 721 | i2c->adap.dev.of_node = pdev->dev.of_node; |
731 | 722 | ||
732 | xiic_reinit(i2c); | ||
733 | |||
734 | spin_lock_init(&i2c->lock); | 723 | spin_lock_init(&i2c->lock); |
735 | init_waitqueue_head(&i2c->wait); | 724 | init_waitqueue_head(&i2c->wait); |
736 | ret = request_irq(irq, xiic_isr, 0, pdev->name, i2c); | 725 | |
737 | if (ret) { | 726 | ret = devm_request_irq(&pdev->dev, irq, xiic_isr, 0, pdev->name, i2c); |
727 | if (ret < 0) { | ||
738 | dev_err(&pdev->dev, "Cannot claim IRQ\n"); | 728 | dev_err(&pdev->dev, "Cannot claim IRQ\n"); |
739 | goto request_irq_failed; | 729 | return ret; |
740 | } | 730 | } |
741 | 731 | ||
732 | xiic_reinit(i2c); | ||
733 | |||
742 | /* add i2c adapter to i2c tree */ | 734 | /* add i2c adapter to i2c tree */ |
743 | ret = i2c_add_adapter(&i2c->adap); | 735 | ret = i2c_add_adapter(&i2c->adap); |
744 | if (ret) { | 736 | if (ret) { |
745 | dev_err(&pdev->dev, "Failed to add adapter\n"); | 737 | dev_err(&pdev->dev, "Failed to add adapter\n"); |
746 | goto add_adapter_failed; | 738 | xiic_deinit(i2c); |
739 | return ret; | ||
747 | } | 740 | } |
748 | 741 | ||
749 | if (pdata) { | 742 | if (pdata) { |
@@ -753,43 +746,17 @@ static int xiic_i2c_probe(struct platform_device *pdev) | |||
753 | } | 746 | } |
754 | 747 | ||
755 | return 0; | 748 | return 0; |
756 | |||
757 | add_adapter_failed: | ||
758 | free_irq(irq, i2c); | ||
759 | request_irq_failed: | ||
760 | xiic_deinit(i2c); | ||
761 | iounmap(i2c->base); | ||
762 | map_failed: | ||
763 | release_mem_region(res->start, resource_size(res)); | ||
764 | request_mem_failed: | ||
765 | kfree(i2c); | ||
766 | |||
767 | return ret; | ||
768 | resource_missing: | ||
769 | dev_err(&pdev->dev, "IRQ or Memory resource is missing\n"); | ||
770 | return -ENOENT; | ||
771 | } | 749 | } |
772 | 750 | ||
773 | static int xiic_i2c_remove(struct platform_device *pdev) | 751 | static int xiic_i2c_remove(struct platform_device *pdev) |
774 | { | 752 | { |
775 | struct xiic_i2c *i2c = platform_get_drvdata(pdev); | 753 | struct xiic_i2c *i2c = platform_get_drvdata(pdev); |
776 | struct resource *res; | ||
777 | 754 | ||
778 | /* remove adapter & data */ | 755 | /* remove adapter & data */ |
779 | i2c_del_adapter(&i2c->adap); | 756 | i2c_del_adapter(&i2c->adap); |
780 | 757 | ||
781 | xiic_deinit(i2c); | 758 | xiic_deinit(i2c); |
782 | 759 | ||
783 | free_irq(platform_get_irq(pdev, 0), i2c); | ||
784 | |||
785 | iounmap(i2c->base); | ||
786 | |||
787 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
788 | if (res) | ||
789 | release_mem_region(res->start, resource_size(res)); | ||
790 | |||
791 | kfree(i2c); | ||
792 | |||
793 | return 0; | 760 | return 0; |
794 | } | 761 | } |
795 | 762 | ||
diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index bad5b84a5985..e835304e7b5a 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c | |||
@@ -35,14 +35,15 @@ | |||
35 | * warranty of any kind, whether express or implied. | 35 | * warranty of any kind, whether express or implied. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | #include <linux/module.h> | ||
39 | #include <linux/init.h> | ||
40 | #include <linux/slab.h> | ||
41 | #include <linux/device.h> | 38 | #include <linux/device.h> |
39 | #include <linux/gpio.h> | ||
42 | #include <linux/i2c.h> | 40 | #include <linux/i2c.h> |
43 | #include <linux/i2c-mux.h> | 41 | #include <linux/i2c-mux.h> |
44 | |||
45 | #include <linux/i2c/pca954x.h> | 42 | #include <linux/i2c/pca954x.h> |
43 | #include <linux/init.h> | ||
44 | #include <linux/module.h> | ||
45 | #include <linux/of_gpio.h> | ||
46 | #include <linux/slab.h> | ||
46 | 47 | ||
47 | #define PCA954X_MAX_NCHANS 8 | 48 | #define PCA954X_MAX_NCHANS 8 |
48 | 49 | ||
@@ -186,28 +187,43 @@ static int pca954x_probe(struct i2c_client *client, | |||
186 | { | 187 | { |
187 | struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); | 188 | struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); |
188 | struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev); | 189 | struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev); |
190 | struct device_node *np = client->dev.of_node; | ||
189 | int num, force, class; | 191 | int num, force, class; |
190 | struct pca954x *data; | 192 | struct pca954x *data; |
191 | int ret = -ENODEV; | 193 | int ret; |
192 | 194 | ||
193 | if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) | 195 | if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) |
194 | goto err; | 196 | return -ENODEV; |
195 | 197 | ||
196 | data = kzalloc(sizeof(struct pca954x), GFP_KERNEL); | 198 | data = devm_kzalloc(&client->dev, sizeof(struct pca954x), GFP_KERNEL); |
197 | if (!data) { | 199 | if (!data) |
198 | ret = -ENOMEM; | 200 | return -ENOMEM; |
199 | goto err; | ||
200 | } | ||
201 | 201 | ||
202 | i2c_set_clientdata(client, data); | 202 | i2c_set_clientdata(client, data); |
203 | 203 | ||
204 | if (IS_ENABLED(CONFIG_OF) && np) { | ||
205 | enum of_gpio_flags flags; | ||
206 | int gpio; | ||
207 | |||
208 | /* Get the mux out of reset if a reset GPIO is specified. */ | ||
209 | gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags); | ||
210 | if (gpio_is_valid(gpio)) { | ||
211 | ret = devm_gpio_request_one(&client->dev, gpio, | ||
212 | flags & OF_GPIO_ACTIVE_LOW ? | ||
213 | GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW, | ||
214 | "pca954x reset"); | ||
215 | if (ret < 0) | ||
216 | return ret; | ||
217 | } | ||
218 | } | ||
219 | |||
204 | /* Write the mux register at addr to verify | 220 | /* Write the mux register at addr to verify |
205 | * that the mux is in fact present. This also | 221 | * that the mux is in fact present. This also |
206 | * initializes the mux to disconnected state. | 222 | * initializes the mux to disconnected state. |
207 | */ | 223 | */ |
208 | if (i2c_smbus_write_byte(client, 0) < 0) { | 224 | if (i2c_smbus_write_byte(client, 0) < 0) { |
209 | dev_warn(&client->dev, "probe failed\n"); | 225 | dev_warn(&client->dev, "probe failed\n"); |
210 | goto exit_free; | 226 | return -ENODEV; |
211 | } | 227 | } |
212 | 228 | ||
213 | data->type = id->driver_data; | 229 | data->type = id->driver_data; |
@@ -252,9 +268,6 @@ static int pca954x_probe(struct i2c_client *client, | |||
252 | virt_reg_failed: | 268 | virt_reg_failed: |
253 | for (num--; num >= 0; num--) | 269 | for (num--; num >= 0; num--) |
254 | i2c_del_mux_adapter(data->virt_adaps[num]); | 270 | i2c_del_mux_adapter(data->virt_adaps[num]); |
255 | exit_free: | ||
256 | kfree(data); | ||
257 | err: | ||
258 | return ret; | 271 | return ret; |
259 | } | 272 | } |
260 | 273 | ||
@@ -270,7 +283,6 @@ static int pca954x_remove(struct i2c_client *client) | |||
270 | data->virt_adaps[i] = NULL; | 283 | data->virt_adaps[i] = NULL; |
271 | } | 284 | } |
272 | 285 | ||
273 | kfree(data); | ||
274 | return 0; | 286 | return 0; |
275 | } | 287 | } |
276 | 288 | ||
diff --git a/include/linux/i2c-pnx.h b/include/linux/i2c-pnx.h index 49ed17fdf055..5388326fbbff 100644 --- a/include/linux/i2c-pnx.h +++ b/include/linux/i2c-pnx.h | |||
@@ -31,7 +31,6 @@ struct i2c_pnx_algo_data { | |||
31 | int last; | 31 | int last; |
32 | struct clk *clk; | 32 | struct clk *clk; |
33 | struct i2c_adapter adapter; | 33 | struct i2c_adapter adapter; |
34 | phys_addr_t base; | ||
35 | int irq; | 34 | int irq; |
36 | u32 timeout; | 35 | u32 timeout; |
37 | }; | 36 | }; |
diff --git a/include/linux/platform_data/i2c-nomadik.h b/include/linux/platform_data/i2c-nomadik.h deleted file mode 100644 index 3a8be9cdc95c..000000000000 --- a/include/linux/platform_data/i2c-nomadik.h +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009 ST-Ericsson | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2, as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | #ifndef __PDATA_I2C_NOMADIK_H | ||
9 | #define __PDATA_I2C_NOMADIK_H | ||
10 | |||
11 | enum i2c_freq_mode { | ||
12 | I2C_FREQ_MODE_STANDARD, /* up to 100 Kb/s */ | ||
13 | I2C_FREQ_MODE_FAST, /* up to 400 Kb/s */ | ||
14 | I2C_FREQ_MODE_HIGH_SPEED, /* up to 3.4 Mb/s */ | ||
15 | I2C_FREQ_MODE_FAST_PLUS, /* up to 1 Mb/s */ | ||
16 | }; | ||
17 | |||
18 | /** | ||
19 | * struct nmk_i2c_controller - client specific controller configuration | ||
20 | * @clk_freq: clock frequency for the operation mode | ||
21 | * @slsu: Slave data setup time in ns. | ||
22 | * The needed setup time for three modes of operation | ||
23 | * are 250ns, 100ns and 10ns respectively thus leading | ||
24 | * to the values of 14, 6, 2 for a 48 MHz i2c clk | ||
25 | * @tft: Tx FIFO Threshold in bytes | ||
26 | * @rft: Rx FIFO Threshold in bytes | ||
27 | * @timeout Slave response timeout(ms) | ||
28 | * @sm: speed mode | ||
29 | */ | ||
30 | struct nmk_i2c_controller { | ||
31 | u32 clk_freq; | ||
32 | unsigned short slsu; | ||
33 | unsigned char tft; | ||
34 | unsigned char rft; | ||
35 | int timeout; | ||
36 | enum i2c_freq_mode sm; | ||
37 | }; | ||
38 | |||
39 | #endif /* __PDATA_I2C_NOMADIK_H */ | ||