diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-06-23 16:20:51 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-06-23 16:20:51 -0400 |
commit | 74d83b7eedab14e4b963a2220ff76f98fa6d4cb8 (patch) | |
tree | ff4b10ebd9cf1a057c4b1a703732858a539faff7 /drivers/i2c | |
parent | 61db1802bf33bf027cd97ba3f79566b2b2fce5c6 (diff) | |
parent | 56299378726d5f2ba8d3c8cbbd13cb280ba45e4f (diff) |
Merge tag 'v3.0-rc4' of /pub/scm/linux/kernel/git/torvalds/linux-2.6 into for-linus
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/Kconfig | 12 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-eg20t.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-gpio.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-i801.c | 60 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-mpc.c | 9 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-nomadik.c | 276 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-ocores.c | 3 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-parport-light.c | 10 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-parport.c | 30 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-parport.h | 74 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-pnx.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-sh_mobile.c | 20 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-tegra.c | 39 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-xiic.c | 3 |
14 files changed, 346 insertions, 196 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 326652f673f7..646068e5100b 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -79,6 +79,7 @@ config I2C_AMD8111 | |||
79 | config I2C_I801 | 79 | config I2C_I801 |
80 | tristate "Intel 82801 (ICH/PCH)" | 80 | tristate "Intel 82801 (ICH/PCH)" |
81 | depends on PCI | 81 | depends on PCI |
82 | select CHECK_SIGNATURE if X86 && DMI | ||
82 | help | 83 | help |
83 | If you say yes to this option, support will be included for the Intel | 84 | If you say yes to this option, support will be included for the Intel |
84 | 801 family of mainboard I2C interfaces. Specifically, the following | 85 | 801 family of mainboard I2C interfaces. Specifically, the following |
@@ -101,6 +102,7 @@ config I2C_I801 | |||
101 | 6 Series (PCH) | 102 | 6 Series (PCH) |
102 | Patsburg (PCH) | 103 | Patsburg (PCH) |
103 | DH89xxCC (PCH) | 104 | DH89xxCC (PCH) |
105 | Panther Point (PCH) | ||
104 | 106 | ||
105 | This driver can also be built as a module. If so, the module | 107 | This driver can also be built as a module. If so, the module |
106 | will be called i2c-i801. | 108 | will be called i2c-i801. |
@@ -671,15 +673,19 @@ config I2C_XILINX | |||
671 | will be called xilinx_i2c. | 673 | will be called xilinx_i2c. |
672 | 674 | ||
673 | config I2C_EG20T | 675 | config I2C_EG20T |
674 | tristate "Intel EG20T PCH/OKI SEMICONDUCTOR ML7213 IOH" | 676 | tristate "Intel EG20T PCH / OKI SEMICONDUCTOR IOH(ML7213/ML7223)" |
675 | depends on PCI | 677 | depends on PCI |
676 | help | 678 | help |
677 | This driver is for PCH(Platform controller Hub) I2C of EG20T which | 679 | This driver is for PCH(Platform controller Hub) I2C of EG20T which |
678 | is an IOH(Input/Output Hub) for x86 embedded processor. | 680 | is an IOH(Input/Output Hub) for x86 embedded processor. |
679 | This driver can access PCH I2C bus device. | 681 | This driver can access PCH I2C bus device. |
680 | 682 | ||
681 | This driver also supports the ML7213, a companion chip for the | 683 | This driver also can be used for OKI SEMICONDUCTOR IOH(Input/ |
682 | Atom E6xx series and compatible with the Intel EG20T PCH. | 684 | Output Hub), ML7213 and ML7223. |
685 | ML7213 IOH is for IVI(In-Vehicle Infotainment) use and ML7223 IOH is | ||
686 | for MP(Media Phone) use. | ||
687 | ML7213/ML7223 is companion chip for Intel Atom E6xx series. | ||
688 | ML7213/ML7223 is completely compatible for Intel EG20T PCH. | ||
683 | 689 | ||
684 | comment "External I2C/SMBus adapter drivers" | 690 | comment "External I2C/SMBus adapter drivers" |
685 | 691 | ||
diff --git a/drivers/i2c/busses/i2c-eg20t.c b/drivers/i2c/busses/i2c-eg20t.c index 878a12026af2..8abfa4a03ce1 100644 --- a/drivers/i2c/busses/i2c-eg20t.c +++ b/drivers/i2c/busses/i2c-eg20t.c | |||
@@ -182,10 +182,12 @@ static DEFINE_MUTEX(pch_mutex); | |||
182 | /* Definition for ML7213 by OKI SEMICONDUCTOR */ | 182 | /* Definition for ML7213 by OKI SEMICONDUCTOR */ |
183 | #define PCI_VENDOR_ID_ROHM 0x10DB | 183 | #define PCI_VENDOR_ID_ROHM 0x10DB |
184 | #define PCI_DEVICE_ID_ML7213_I2C 0x802D | 184 | #define PCI_DEVICE_ID_ML7213_I2C 0x802D |
185 | #define PCI_DEVICE_ID_ML7223_I2C 0x8010 | ||
185 | 186 | ||
186 | static struct pci_device_id __devinitdata pch_pcidev_id[] = { | 187 | static struct pci_device_id __devinitdata pch_pcidev_id[] = { |
187 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PCH_I2C), 1, }, | 188 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PCH_I2C), 1, }, |
188 | { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7213_I2C), 2, }, | 189 | { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7213_I2C), 2, }, |
190 | { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7223_I2C), 1, }, | ||
189 | {0,} | 191 | {0,} |
190 | }; | 192 | }; |
191 | 193 | ||
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index d9aa9a649e35..a651779d9ff7 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c | |||
@@ -219,7 +219,7 @@ static void __exit i2c_gpio_exit(void) | |||
219 | } | 219 | } |
220 | module_exit(i2c_gpio_exit); | 220 | module_exit(i2c_gpio_exit); |
221 | 221 | ||
222 | MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>"); | 222 | MODULE_AUTHOR("Haavard Skinnemoen (Atmel)"); |
223 | MODULE_DESCRIPTION("Platform-independent bitbanging I2C driver"); | 223 | MODULE_DESCRIPTION("Platform-independent bitbanging I2C driver"); |
224 | MODULE_LICENSE("GPL"); | 224 | MODULE_LICENSE("GPL"); |
225 | MODULE_ALIAS("platform:i2c-gpio"); | 225 | MODULE_ALIAS("platform:i2c-gpio"); |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 455e909bc768..ab26840d0c70 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -50,6 +50,7 @@ | |||
50 | Patsburg (PCH) IDF 0x1d71 32 hard yes yes yes | 50 | Patsburg (PCH) IDF 0x1d71 32 hard yes yes yes |
51 | Patsburg (PCH) IDF 0x1d72 32 hard yes yes yes | 51 | Patsburg (PCH) IDF 0x1d72 32 hard yes yes yes |
52 | DH89xxCC (PCH) 0x2330 32 hard yes yes yes | 52 | DH89xxCC (PCH) 0x2330 32 hard yes yes yes |
53 | Panther Point (PCH) 0x1e22 32 hard yes yes yes | ||
53 | 54 | ||
54 | Features supported by this driver: | 55 | Features supported by this driver: |
55 | Software PEC no | 56 | Software PEC no |
@@ -141,6 +142,7 @@ | |||
141 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0 0x1d70 | 142 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0 0x1d70 |
142 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1 0x1d71 | 143 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1 0x1d71 |
143 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2 0x1d72 | 144 | #define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2 0x1d72 |
145 | #define PCI_DEVICE_ID_INTEL_PANTHERPOINT_SMBUS 0x1e22 | ||
144 | #define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS 0x2330 | 146 | #define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS 0x2330 |
145 | #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS 0x3b30 | 147 | #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS 0x3b30 |
146 | 148 | ||
@@ -158,6 +160,8 @@ static struct pci_driver i801_driver; | |||
158 | #define FEATURE_BLOCK_BUFFER (1 << 1) | 160 | #define FEATURE_BLOCK_BUFFER (1 << 1) |
159 | #define FEATURE_BLOCK_PROC (1 << 2) | 161 | #define FEATURE_BLOCK_PROC (1 << 2) |
160 | #define FEATURE_I2C_BLOCK_READ (1 << 3) | 162 | #define FEATURE_I2C_BLOCK_READ (1 << 3) |
163 | /* Not really a feature, but it's convenient to handle it as such */ | ||
164 | #define FEATURE_IDF (1 << 15) | ||
161 | 165 | ||
162 | static const char *i801_feature_names[] = { | 166 | static const char *i801_feature_names[] = { |
163 | "SMBus PEC", | 167 | "SMBus PEC", |
@@ -628,12 +632,13 @@ static const struct pci_device_id i801_ids[] = { | |||
628 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1) }, | 632 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1) }, |
629 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2) }, | 633 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2) }, |
630 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS) }, | 634 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS) }, |
635 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PANTHERPOINT_SMBUS) }, | ||
631 | { 0, } | 636 | { 0, } |
632 | }; | 637 | }; |
633 | 638 | ||
634 | MODULE_DEVICE_TABLE(pci, i801_ids); | 639 | MODULE_DEVICE_TABLE(pci, i801_ids); |
635 | 640 | ||
636 | #if defined CONFIG_INPUT_APANEL || defined CONFIG_INPUT_APANEL_MODULE | 641 | #if defined CONFIG_X86 && defined CONFIG_DMI |
637 | static unsigned char apanel_addr; | 642 | static unsigned char apanel_addr; |
638 | 643 | ||
639 | /* Scan the system ROM for the signature "FJKEYINF" */ | 644 | /* Scan the system ROM for the signature "FJKEYINF" */ |
@@ -663,11 +668,7 @@ static void __init input_apanel_init(void) | |||
663 | } | 668 | } |
664 | iounmap(bios); | 669 | iounmap(bios); |
665 | } | 670 | } |
666 | #else | ||
667 | static void __init input_apanel_init(void) {} | ||
668 | #endif | ||
669 | 671 | ||
670 | #if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE | ||
671 | struct dmi_onboard_device_info { | 672 | struct dmi_onboard_device_info { |
672 | const char *name; | 673 | const char *name; |
673 | u8 type; | 674 | u8 type; |
@@ -733,7 +734,30 @@ static void __devinit dmi_check_onboard_devices(const struct dmi_header *dm, | |||
733 | dmi_check_onboard_device(type, name, adap); | 734 | dmi_check_onboard_device(type, name, adap); |
734 | } | 735 | } |
735 | } | 736 | } |
736 | #endif | 737 | |
738 | /* Register optional slaves */ | ||
739 | static void __devinit i801_probe_optional_slaves(struct i801_priv *priv) | ||
740 | { | ||
741 | /* Only register slaves on main SMBus channel */ | ||
742 | if (priv->features & FEATURE_IDF) | ||
743 | return; | ||
744 | |||
745 | if (apanel_addr) { | ||
746 | struct i2c_board_info info; | ||
747 | |||
748 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
749 | info.addr = apanel_addr; | ||
750 | strlcpy(info.type, "fujitsu_apanel", I2C_NAME_SIZE); | ||
751 | i2c_new_device(&priv->adapter, &info); | ||
752 | } | ||
753 | |||
754 | if (dmi_name_in_vendors("FUJITSU")) | ||
755 | dmi_walk(dmi_check_onboard_devices, &priv->adapter); | ||
756 | } | ||
757 | #else | ||
758 | static void __init input_apanel_init(void) {} | ||
759 | static void __devinit i801_probe_optional_slaves(struct i801_priv *priv) {} | ||
760 | #endif /* CONFIG_X86 && CONFIG_DMI */ | ||
737 | 761 | ||
738 | static int __devinit i801_probe(struct pci_dev *dev, | 762 | static int __devinit i801_probe(struct pci_dev *dev, |
739 | const struct pci_device_id *id) | 763 | const struct pci_device_id *id) |
@@ -753,6 +777,11 @@ static int __devinit i801_probe(struct pci_dev *dev, | |||
753 | 777 | ||
754 | priv->pci_dev = dev; | 778 | priv->pci_dev = dev; |
755 | switch (dev->device) { | 779 | switch (dev->device) { |
780 | case PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0: | ||
781 | case PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1: | ||
782 | case PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2: | ||
783 | priv->features |= FEATURE_IDF; | ||
784 | /* fall through */ | ||
756 | default: | 785 | default: |
757 | priv->features |= FEATURE_I2C_BLOCK_READ; | 786 | priv->features |= FEATURE_I2C_BLOCK_READ; |
758 | /* fall through */ | 787 | /* fall through */ |
@@ -838,21 +867,7 @@ static int __devinit i801_probe(struct pci_dev *dev, | |||
838 | goto exit_release; | 867 | goto exit_release; |
839 | } | 868 | } |
840 | 869 | ||
841 | /* Register optional slaves */ | 870 | i801_probe_optional_slaves(priv); |
842 | #if defined CONFIG_INPUT_APANEL || defined CONFIG_INPUT_APANEL_MODULE | ||
843 | if (apanel_addr) { | ||
844 | struct i2c_board_info info; | ||
845 | |||
846 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
847 | info.addr = apanel_addr; | ||
848 | strlcpy(info.type, "fujitsu_apanel", I2C_NAME_SIZE); | ||
849 | i2c_new_device(&priv->adapter, &info); | ||
850 | } | ||
851 | #endif | ||
852 | #if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE | ||
853 | if (dmi_name_in_vendors("FUJITSU")) | ||
854 | dmi_walk(dmi_check_onboard_devices, &priv->adapter); | ||
855 | #endif | ||
856 | 871 | ||
857 | pci_set_drvdata(dev, priv); | 872 | pci_set_drvdata(dev, priv); |
858 | return 0; | 873 | return 0; |
@@ -912,7 +927,8 @@ static struct pci_driver i801_driver = { | |||
912 | 927 | ||
913 | static int __init i2c_i801_init(void) | 928 | static int __init i2c_i801_init(void) |
914 | { | 929 | { |
915 | input_apanel_init(); | 930 | if (dmi_name_in_vendors("FUJITSU")) |
931 | input_apanel_init(); | ||
916 | return pci_register_driver(&i801_driver); | 932 | return pci_register_driver(&i801_driver); |
917 | } | 933 | } |
918 | 934 | ||
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 75b984c519ac..107397a606b4 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -560,15 +560,18 @@ static struct i2c_adapter mpc_ops = { | |||
560 | .timeout = HZ, | 560 | .timeout = HZ, |
561 | }; | 561 | }; |
562 | 562 | ||
563 | static const struct of_device_id mpc_i2c_of_match[]; | ||
563 | static int __devinit fsl_i2c_probe(struct platform_device *op) | 564 | static int __devinit fsl_i2c_probe(struct platform_device *op) |
564 | { | 565 | { |
566 | const struct of_device_id *match; | ||
565 | struct mpc_i2c *i2c; | 567 | struct mpc_i2c *i2c; |
566 | const u32 *prop; | 568 | const u32 *prop; |
567 | u32 clock = MPC_I2C_CLOCK_LEGACY; | 569 | u32 clock = MPC_I2C_CLOCK_LEGACY; |
568 | int result = 0; | 570 | int result = 0; |
569 | int plen; | 571 | int plen; |
570 | 572 | ||
571 | if (!op->dev.of_match) | 573 | match = of_match_device(mpc_i2c_of_match, &op->dev); |
574 | if (!match) | ||
572 | return -EINVAL; | 575 | return -EINVAL; |
573 | 576 | ||
574 | i2c = kzalloc(sizeof(*i2c), GFP_KERNEL); | 577 | i2c = kzalloc(sizeof(*i2c), GFP_KERNEL); |
@@ -605,8 +608,8 @@ static int __devinit fsl_i2c_probe(struct platform_device *op) | |||
605 | clock = *prop; | 608 | clock = *prop; |
606 | } | 609 | } |
607 | 610 | ||
608 | if (op->dev.of_match->data) { | 611 | if (match->data) { |
609 | struct mpc_i2c_data *data = op->dev.of_match->data; | 612 | struct mpc_i2c_data *data = match->data; |
610 | data->setup(op->dev.of_node, i2c, clock, data->prescaler); | 613 | data->setup(op->dev.of_node, i2c, clock, data->prescaler); |
611 | } else { | 614 | } else { |
612 | /* Backwards compatibility */ | 615 | /* Backwards compatibility */ |
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index e10e5cf3751a..0c731ca69f15 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c | |||
@@ -15,13 +15,14 @@ | |||
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/delay.h> | ||
19 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
20 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
21 | #include <linux/i2c.h> | 20 | #include <linux/i2c.h> |
22 | #include <linux/err.h> | 21 | #include <linux/err.h> |
23 | #include <linux/clk.h> | 22 | #include <linux/clk.h> |
24 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <linux/regulator/consumer.h> | ||
25 | #include <linux/pm_runtime.h> | ||
25 | 26 | ||
26 | #include <plat/i2c.h> | 27 | #include <plat/i2c.h> |
27 | 28 | ||
@@ -103,9 +104,6 @@ | |||
103 | /* maximum threshold value */ | 104 | /* maximum threshold value */ |
104 | #define MAX_I2C_FIFO_THRESHOLD 15 | 105 | #define MAX_I2C_FIFO_THRESHOLD 15 |
105 | 106 | ||
106 | /* per-transfer delay, required for the hardware to stabilize */ | ||
107 | #define I2C_DELAY 150 | ||
108 | |||
109 | enum i2c_status { | 107 | enum i2c_status { |
110 | I2C_NOP, | 108 | I2C_NOP, |
111 | I2C_ON_GOING, | 109 | I2C_ON_GOING, |
@@ -120,9 +118,6 @@ enum i2c_operation { | |||
120 | I2C_READ = 0x01 | 118 | I2C_READ = 0x01 |
121 | }; | 119 | }; |
122 | 120 | ||
123 | /* controller response timeout in ms */ | ||
124 | #define I2C_TIMEOUT_MS 2000 | ||
125 | |||
126 | /** | 121 | /** |
127 | * struct i2c_nmk_client - client specific data | 122 | * struct i2c_nmk_client - client specific data |
128 | * @slave_adr: 7-bit slave address | 123 | * @slave_adr: 7-bit slave address |
@@ -151,6 +146,7 @@ struct i2c_nmk_client { | |||
151 | * @stop: stop condition | 146 | * @stop: stop condition |
152 | * @xfer_complete: acknowledge completion for a I2C message | 147 | * @xfer_complete: acknowledge completion for a I2C message |
153 | * @result: controller propogated result | 148 | * @result: controller propogated result |
149 | * @busy: Busy doing transfer | ||
154 | */ | 150 | */ |
155 | struct nmk_i2c_dev { | 151 | struct nmk_i2c_dev { |
156 | struct platform_device *pdev; | 152 | struct platform_device *pdev; |
@@ -163,6 +159,8 @@ struct nmk_i2c_dev { | |||
163 | int stop; | 159 | int stop; |
164 | struct completion xfer_complete; | 160 | struct completion xfer_complete; |
165 | int result; | 161 | int result; |
162 | struct regulator *regulator; | ||
163 | bool busy; | ||
166 | }; | 164 | }; |
167 | 165 | ||
168 | /* controller's abort causes */ | 166 | /* controller's abort causes */ |
@@ -209,7 +207,7 @@ static int flush_i2c_fifo(struct nmk_i2c_dev *dev) | |||
209 | writel((I2C_CR_FTX | I2C_CR_FRX), dev->virtbase + I2C_CR); | 207 | writel((I2C_CR_FTX | I2C_CR_FRX), dev->virtbase + I2C_CR); |
210 | 208 | ||
211 | for (i = 0; i < LOOP_ATTEMPTS; i++) { | 209 | for (i = 0; i < LOOP_ATTEMPTS; i++) { |
212 | timeout = jiffies + msecs_to_jiffies(I2C_TIMEOUT_MS); | 210 | timeout = jiffies + dev->adap.timeout; |
213 | 211 | ||
214 | while (!time_after(jiffies, timeout)) { | 212 | while (!time_after(jiffies, timeout)) { |
215 | if ((readl(dev->virtbase + I2C_CR) & | 213 | if ((readl(dev->virtbase + I2C_CR) & |
@@ -253,11 +251,9 @@ static int init_hw(struct nmk_i2c_dev *dev) | |||
253 | { | 251 | { |
254 | int stat; | 252 | int stat; |
255 | 253 | ||
256 | clk_enable(dev->clk); | ||
257 | |||
258 | stat = flush_i2c_fifo(dev); | 254 | stat = flush_i2c_fifo(dev); |
259 | if (stat) | 255 | if (stat) |
260 | return stat; | 256 | goto exit; |
261 | 257 | ||
262 | /* disable the controller */ | 258 | /* disable the controller */ |
263 | i2c_clr_bit(dev->virtbase + I2C_CR , I2C_CR_PE); | 259 | i2c_clr_bit(dev->virtbase + I2C_CR , I2C_CR_PE); |
@@ -268,10 +264,8 @@ static int init_hw(struct nmk_i2c_dev *dev) | |||
268 | 264 | ||
269 | dev->cli.operation = I2C_NO_OPERATION; | 265 | dev->cli.operation = I2C_NO_OPERATION; |
270 | 266 | ||
271 | clk_disable(dev->clk); | 267 | exit: |
272 | 268 | return stat; | |
273 | udelay(I2C_DELAY); | ||
274 | return 0; | ||
275 | } | 269 | } |
276 | 270 | ||
277 | /* enable peripheral, master mode operation */ | 271 | /* enable peripheral, master mode operation */ |
@@ -424,7 +418,7 @@ static int read_i2c(struct nmk_i2c_dev *dev) | |||
424 | dev->virtbase + I2C_IMSCR); | 418 | dev->virtbase + I2C_IMSCR); |
425 | 419 | ||
426 | timeout = wait_for_completion_interruptible_timeout( | 420 | timeout = wait_for_completion_interruptible_timeout( |
427 | &dev->xfer_complete, msecs_to_jiffies(I2C_TIMEOUT_MS)); | 421 | &dev->xfer_complete, dev->adap.timeout); |
428 | 422 | ||
429 | if (timeout < 0) { | 423 | if (timeout < 0) { |
430 | dev_err(&dev->pdev->dev, | 424 | dev_err(&dev->pdev->dev, |
@@ -434,14 +428,32 @@ static int read_i2c(struct nmk_i2c_dev *dev) | |||
434 | } | 428 | } |
435 | 429 | ||
436 | if (timeout == 0) { | 430 | if (timeout == 0) { |
437 | /* controller has timedout, re-init the h/w */ | 431 | /* Controller timed out */ |
438 | dev_err(&dev->pdev->dev, "controller timed out, re-init h/w\n"); | 432 | dev_err(&dev->pdev->dev, "read from slave 0x%x timed out\n", |
439 | (void) init_hw(dev); | 433 | dev->cli.slave_adr); |
440 | status = -ETIMEDOUT; | 434 | status = -ETIMEDOUT; |
441 | } | 435 | } |
442 | return status; | 436 | return status; |
443 | } | 437 | } |
444 | 438 | ||
439 | static void fill_tx_fifo(struct nmk_i2c_dev *dev, int no_bytes) | ||
440 | { | ||
441 | int count; | ||
442 | |||
443 | for (count = (no_bytes - 2); | ||
444 | (count > 0) && | ||
445 | (dev->cli.count != 0); | ||
446 | count--) { | ||
447 | /* write to the Tx FIFO */ | ||
448 | writeb(*dev->cli.buffer, | ||
449 | dev->virtbase + I2C_TFR); | ||
450 | dev->cli.buffer++; | ||
451 | dev->cli.count--; | ||
452 | dev->cli.xfer_bytes++; | ||
453 | } | ||
454 | |||
455 | } | ||
456 | |||
445 | /** | 457 | /** |
446 | * write_i2c() - Write data to I2C client. | 458 | * write_i2c() - Write data to I2C client. |
447 | * @dev: private data of I2C Driver | 459 | * @dev: private data of I2C Driver |
@@ -469,8 +481,13 @@ static int write_i2c(struct nmk_i2c_dev *dev) | |||
469 | init_completion(&dev->xfer_complete); | 481 | init_completion(&dev->xfer_complete); |
470 | 482 | ||
471 | /* enable interrupts by settings the masks */ | 483 | /* enable interrupts by settings the masks */ |
472 | irq_mask = (I2C_IT_TXFNE | I2C_IT_TXFOVR | | 484 | irq_mask = (I2C_IT_TXFOVR | I2C_IT_MAL | I2C_IT_BERR); |
473 | I2C_IT_MAL | I2C_IT_BERR); | 485 | |
486 | /* Fill the TX FIFO with transmit data */ | ||
487 | fill_tx_fifo(dev, MAX_I2C_FIFO_THRESHOLD); | ||
488 | |||
489 | if (dev->cli.count != 0) | ||
490 | irq_mask |= I2C_IT_TXFNE; | ||
474 | 491 | ||
475 | /* | 492 | /* |
476 | * check if we want to transfer a single or multiple bytes, if so | 493 | * check if we want to transfer a single or multiple bytes, if so |
@@ -488,7 +505,7 @@ static int write_i2c(struct nmk_i2c_dev *dev) | |||
488 | dev->virtbase + I2C_IMSCR); | 505 | dev->virtbase + I2C_IMSCR); |
489 | 506 | ||
490 | timeout = wait_for_completion_interruptible_timeout( | 507 | timeout = wait_for_completion_interruptible_timeout( |
491 | &dev->xfer_complete, msecs_to_jiffies(I2C_TIMEOUT_MS)); | 508 | &dev->xfer_complete, dev->adap.timeout); |
492 | 509 | ||
493 | if (timeout < 0) { | 510 | if (timeout < 0) { |
494 | dev_err(&dev->pdev->dev, | 511 | dev_err(&dev->pdev->dev, |
@@ -498,9 +515,9 @@ static int write_i2c(struct nmk_i2c_dev *dev) | |||
498 | } | 515 | } |
499 | 516 | ||
500 | if (timeout == 0) { | 517 | if (timeout == 0) { |
501 | /* controller has timedout, re-init the h/w */ | 518 | /* Controller timed out */ |
502 | dev_err(&dev->pdev->dev, "controller timed out, re-init h/w\n"); | 519 | dev_err(&dev->pdev->dev, "write to slave 0x%x timed out\n", |
503 | (void) init_hw(dev); | 520 | dev->cli.slave_adr); |
504 | status = -ETIMEDOUT; | 521 | status = -ETIMEDOUT; |
505 | } | 522 | } |
506 | 523 | ||
@@ -508,6 +525,51 @@ static int write_i2c(struct nmk_i2c_dev *dev) | |||
508 | } | 525 | } |
509 | 526 | ||
510 | /** | 527 | /** |
528 | * nmk_i2c_xfer_one() - transmit a single I2C message | ||
529 | * @dev: device with a message encoded into it | ||
530 | * @flags: message flags | ||
531 | */ | ||
532 | static int nmk_i2c_xfer_one(struct nmk_i2c_dev *dev, u16 flags) | ||
533 | { | ||
534 | int status; | ||
535 | |||
536 | if (flags & I2C_M_RD) { | ||
537 | /* read operation */ | ||
538 | dev->cli.operation = I2C_READ; | ||
539 | status = read_i2c(dev); | ||
540 | } else { | ||
541 | /* write operation */ | ||
542 | dev->cli.operation = I2C_WRITE; | ||
543 | status = write_i2c(dev); | ||
544 | } | ||
545 | |||
546 | if (status || (dev->result)) { | ||
547 | u32 i2c_sr; | ||
548 | u32 cause; | ||
549 | |||
550 | i2c_sr = readl(dev->virtbase + I2C_SR); | ||
551 | /* | ||
552 | * Check if the controller I2C operation status | ||
553 | * is set to ABORT(11b). | ||
554 | */ | ||
555 | if (((i2c_sr >> 2) & 0x3) == 0x3) { | ||
556 | /* get the abort cause */ | ||
557 | cause = (i2c_sr >> 4) & 0x7; | ||
558 | dev_err(&dev->pdev->dev, "%s\n", cause | ||
559 | >= ARRAY_SIZE(abort_causes) ? | ||
560 | "unknown reason" : | ||
561 | abort_causes[cause]); | ||
562 | } | ||
563 | |||
564 | (void) init_hw(dev); | ||
565 | |||
566 | status = status ? status : dev->result; | ||
567 | } | ||
568 | |||
569 | return status; | ||
570 | } | ||
571 | |||
572 | /** | ||
511 | * nmk_i2c_xfer() - I2C transfer function used by kernel framework | 573 | * nmk_i2c_xfer() - I2C transfer function used by kernel framework |
512 | * @i2c_adap: Adapter pointer to the controller | 574 | * @i2c_adap: Adapter pointer to the controller |
513 | * @msgs: Pointer to data to be written. | 575 | * @msgs: Pointer to data to be written. |
@@ -559,53 +621,55 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
559 | { | 621 | { |
560 | int status; | 622 | int status; |
561 | int i; | 623 | int i; |
562 | u32 cause; | ||
563 | struct nmk_i2c_dev *dev = i2c_get_adapdata(i2c_adap); | 624 | struct nmk_i2c_dev *dev = i2c_get_adapdata(i2c_adap); |
625 | int j; | ||
626 | |||
627 | dev->busy = true; | ||
628 | |||
629 | if (dev->regulator) | ||
630 | regulator_enable(dev->regulator); | ||
631 | pm_runtime_get_sync(&dev->pdev->dev); | ||
632 | |||
633 | clk_enable(dev->clk); | ||
564 | 634 | ||
565 | status = init_hw(dev); | 635 | status = init_hw(dev); |
566 | if (status) | 636 | if (status) |
567 | return status; | 637 | goto out; |
568 | 638 | ||
569 | clk_enable(dev->clk); | 639 | /* Attempt three times to send the message queue */ |
640 | for (j = 0; j < 3; j++) { | ||
641 | /* setup the i2c controller */ | ||
642 | setup_i2c_controller(dev); | ||
570 | 643 | ||
571 | /* setup the i2c controller */ | 644 | for (i = 0; i < num_msgs; i++) { |
572 | setup_i2c_controller(dev); | 645 | if (unlikely(msgs[i].flags & I2C_M_TEN)) { |
646 | dev_err(&dev->pdev->dev, "10 bit addressing" | ||
647 | "not supported\n"); | ||
573 | 648 | ||
574 | for (i = 0; i < num_msgs; i++) { | 649 | status = -EINVAL; |
575 | if (unlikely(msgs[i].flags & I2C_M_TEN)) { | 650 | goto out; |
576 | dev_err(&dev->pdev->dev, "10 bit addressing" | 651 | } |
577 | "not supported\n"); | 652 | dev->cli.slave_adr = msgs[i].addr; |
578 | return -EINVAL; | 653 | dev->cli.buffer = msgs[i].buf; |
579 | } | 654 | dev->cli.count = msgs[i].len; |
580 | dev->cli.slave_adr = msgs[i].addr; | 655 | dev->stop = (i < (num_msgs - 1)) ? 0 : 1; |
581 | dev->cli.buffer = msgs[i].buf; | 656 | dev->result = 0; |
582 | dev->cli.count = msgs[i].len; | 657 | |
583 | dev->stop = (i < (num_msgs - 1)) ? 0 : 1; | 658 | status = nmk_i2c_xfer_one(dev, msgs[i].flags); |
584 | dev->result = 0; | 659 | if (status != 0) |
585 | 660 | break; | |
586 | if (msgs[i].flags & I2C_M_RD) { | ||
587 | /* it is a read operation */ | ||
588 | dev->cli.operation = I2C_READ; | ||
589 | status = read_i2c(dev); | ||
590 | } else { | ||
591 | /* write operation */ | ||
592 | dev->cli.operation = I2C_WRITE; | ||
593 | status = write_i2c(dev); | ||
594 | } | ||
595 | if (status || (dev->result)) { | ||
596 | /* get the abort cause */ | ||
597 | cause = (readl(dev->virtbase + I2C_SR) >> 4) & 0x7; | ||
598 | dev_err(&dev->pdev->dev, "error during I2C" | ||
599 | "message xfer: %d\n", cause); | ||
600 | dev_err(&dev->pdev->dev, "%s\n", | ||
601 | cause >= ARRAY_SIZE(abort_causes) | ||
602 | ? "unknown reason" : abort_causes[cause]); | ||
603 | clk_disable(dev->clk); | ||
604 | return status; | ||
605 | } | 661 | } |
606 | udelay(I2C_DELAY); | 662 | if (status == 0) |
663 | break; | ||
607 | } | 664 | } |
665 | |||
666 | out: | ||
608 | clk_disable(dev->clk); | 667 | clk_disable(dev->clk); |
668 | pm_runtime_put_sync(&dev->pdev->dev); | ||
669 | if (dev->regulator) | ||
670 | regulator_disable(dev->regulator); | ||
671 | |||
672 | dev->busy = false; | ||
609 | 673 | ||
610 | /* return the no. messages processed */ | 674 | /* return the no. messages processed */ |
611 | if (status) | 675 | if (status) |
@@ -666,17 +730,7 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) | |||
666 | */ | 730 | */ |
667 | disable_interrupts(dev, I2C_IT_TXFNE); | 731 | disable_interrupts(dev, I2C_IT_TXFNE); |
668 | } else { | 732 | } else { |
669 | for (count = (MAX_I2C_FIFO_THRESHOLD - tft - 2); | 733 | fill_tx_fifo(dev, (MAX_I2C_FIFO_THRESHOLD - tft)); |
670 | (count > 0) && | ||
671 | (dev->cli.count != 0); | ||
672 | count--) { | ||
673 | /* write to the Tx FIFO */ | ||
674 | writeb(*dev->cli.buffer, | ||
675 | dev->virtbase + I2C_TFR); | ||
676 | dev->cli.buffer++; | ||
677 | dev->cli.count--; | ||
678 | dev->cli.xfer_bytes++; | ||
679 | } | ||
680 | /* | 734 | /* |
681 | * if done, close the transfer by disabling the | 735 | * if done, close the transfer by disabling the |
682 | * corresponding TXFNE interrupt | 736 | * corresponding TXFNE interrupt |
@@ -729,16 +783,11 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) | |||
729 | } | 783 | } |
730 | } | 784 | } |
731 | 785 | ||
732 | i2c_set_bit(dev->virtbase + I2C_ICR, I2C_IT_MTD); | 786 | disable_all_interrupts(dev); |
733 | i2c_set_bit(dev->virtbase + I2C_ICR, I2C_IT_MTDWS); | 787 | clear_all_interrupts(dev); |
734 | |||
735 | disable_interrupts(dev, | ||
736 | (I2C_IT_TXFNE | I2C_IT_TXFE | I2C_IT_TXFF | ||
737 | | I2C_IT_TXFOVR | I2C_IT_RXFNF | ||
738 | | I2C_IT_RXFF | I2C_IT_RXFE)); | ||
739 | 788 | ||
740 | if (dev->cli.count) { | 789 | if (dev->cli.count) { |
741 | dev->result = -1; | 790 | dev->result = -EIO; |
742 | dev_err(&dev->pdev->dev, "%lu bytes still remain to be" | 791 | dev_err(&dev->pdev->dev, "%lu bytes still remain to be" |
743 | "xfered\n", dev->cli.count); | 792 | "xfered\n", dev->cli.count); |
744 | (void) init_hw(dev); | 793 | (void) init_hw(dev); |
@@ -749,7 +798,7 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) | |||
749 | 798 | ||
750 | /* Master Arbitration lost interrupt */ | 799 | /* Master Arbitration lost interrupt */ |
751 | case I2C_IT_MAL: | 800 | case I2C_IT_MAL: |
752 | dev->result = -1; | 801 | dev->result = -EIO; |
753 | (void) init_hw(dev); | 802 | (void) init_hw(dev); |
754 | 803 | ||
755 | i2c_set_bit(dev->virtbase + I2C_ICR, I2C_IT_MAL); | 804 | i2c_set_bit(dev->virtbase + I2C_ICR, I2C_IT_MAL); |
@@ -763,7 +812,7 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) | |||
763 | * during the transaction. | 812 | * during the transaction. |
764 | */ | 813 | */ |
765 | case I2C_IT_BERR: | 814 | case I2C_IT_BERR: |
766 | dev->result = -1; | 815 | dev->result = -EIO; |
767 | /* get the status */ | 816 | /* get the status */ |
768 | if (((readl(dev->virtbase + I2C_SR) >> 2) & 0x3) == I2C_ABORT) | 817 | if (((readl(dev->virtbase + I2C_SR) >> 2) & 0x3) == I2C_ABORT) |
769 | (void) init_hw(dev); | 818 | (void) init_hw(dev); |
@@ -779,7 +828,7 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) | |||
779 | * the Tx FIFO is full. | 828 | * the Tx FIFO is full. |
780 | */ | 829 | */ |
781 | case I2C_IT_TXFOVR: | 830 | case I2C_IT_TXFOVR: |
782 | dev->result = -1; | 831 | dev->result = -EIO; |
783 | (void) init_hw(dev); | 832 | (void) init_hw(dev); |
784 | 833 | ||
785 | dev_err(&dev->pdev->dev, "Tx Fifo Over run\n"); | 834 | dev_err(&dev->pdev->dev, "Tx Fifo Over run\n"); |
@@ -805,6 +854,38 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) | |||
805 | return IRQ_HANDLED; | 854 | return IRQ_HANDLED; |
806 | } | 855 | } |
807 | 856 | ||
857 | |||
858 | #ifdef CONFIG_PM | ||
859 | static int nmk_i2c_suspend(struct device *dev) | ||
860 | { | ||
861 | struct platform_device *pdev = to_platform_device(dev); | ||
862 | struct nmk_i2c_dev *nmk_i2c = platform_get_drvdata(pdev); | ||
863 | |||
864 | if (nmk_i2c->busy) | ||
865 | return -EBUSY; | ||
866 | |||
867 | return 0; | ||
868 | } | ||
869 | |||
870 | static int nmk_i2c_resume(struct device *dev) | ||
871 | { | ||
872 | return 0; | ||
873 | } | ||
874 | #else | ||
875 | #define nmk_i2c_suspend NULL | ||
876 | #define nmk_i2c_resume NULL | ||
877 | #endif | ||
878 | |||
879 | /* | ||
880 | * We use noirq so that we suspend late and resume before the wakeup interrupt | ||
881 | * to ensure that we do the !pm_runtime_suspended() check in resume before | ||
882 | * there has been a regular pm runtime resume (via pm_runtime_get_sync()). | ||
883 | */ | ||
884 | static const struct dev_pm_ops nmk_i2c_pm = { | ||
885 | .suspend_noirq = nmk_i2c_suspend, | ||
886 | .resume_noirq = nmk_i2c_resume, | ||
887 | }; | ||
888 | |||
808 | static unsigned int nmk_i2c_functionality(struct i2c_adapter *adap) | 889 | static unsigned int nmk_i2c_functionality(struct i2c_adapter *adap) |
809 | { | 890 | { |
810 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; | 891 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; |
@@ -830,7 +911,7 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev) | |||
830 | ret = -ENOMEM; | 911 | ret = -ENOMEM; |
831 | goto err_no_mem; | 912 | goto err_no_mem; |
832 | } | 913 | } |
833 | 914 | dev->busy = false; | |
834 | dev->pdev = pdev; | 915 | dev->pdev = pdev; |
835 | platform_set_drvdata(pdev, dev); | 916 | platform_set_drvdata(pdev, dev); |
836 | 917 | ||
@@ -860,6 +941,15 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev) | |||
860 | goto err_irq; | 941 | goto err_irq; |
861 | } | 942 | } |
862 | 943 | ||
944 | dev->regulator = regulator_get(&pdev->dev, "v-i2c"); | ||
945 | if (IS_ERR(dev->regulator)) { | ||
946 | dev_warn(&pdev->dev, "could not get i2c regulator\n"); | ||
947 | dev->regulator = NULL; | ||
948 | } | ||
949 | |||
950 | pm_suspend_ignore_children(&pdev->dev, true); | ||
951 | pm_runtime_enable(&pdev->dev); | ||
952 | |||
863 | dev->clk = clk_get(&pdev->dev, NULL); | 953 | dev->clk = clk_get(&pdev->dev, NULL); |
864 | if (IS_ERR(dev->clk)) { | 954 | if (IS_ERR(dev->clk)) { |
865 | dev_err(&pdev->dev, "could not get i2c clock\n"); | 955 | dev_err(&pdev->dev, "could not get i2c clock\n"); |
@@ -872,6 +962,8 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev) | |||
872 | adap->owner = THIS_MODULE; | 962 | adap->owner = THIS_MODULE; |
873 | adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; | 963 | adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; |
874 | adap->algo = &nmk_i2c_algo; | 964 | adap->algo = &nmk_i2c_algo; |
965 | adap->timeout = pdata->timeout ? msecs_to_jiffies(pdata->timeout) : | ||
966 | msecs_to_jiffies(20000); | ||
875 | snprintf(adap->name, sizeof(adap->name), | 967 | snprintf(adap->name, sizeof(adap->name), |
876 | "Nomadik I2C%d at %lx", pdev->id, (unsigned long)res->start); | 968 | "Nomadik I2C%d at %lx", pdev->id, (unsigned long)res->start); |
877 | 969 | ||
@@ -887,12 +979,6 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev) | |||
887 | 979 | ||
888 | i2c_set_adapdata(adap, dev); | 980 | i2c_set_adapdata(adap, dev); |
889 | 981 | ||
890 | ret = init_hw(dev); | ||
891 | if (ret != 0) { | ||
892 | dev_err(&pdev->dev, "error in initializing i2c hardware\n"); | ||
893 | goto err_init_hw; | ||
894 | } | ||
895 | |||
896 | dev_info(&pdev->dev, "initialize %s on virtual " | 982 | dev_info(&pdev->dev, "initialize %s on virtual " |
897 | "base %p\n", adap->name, dev->virtbase); | 983 | "base %p\n", adap->name, dev->virtbase); |
898 | 984 | ||
@@ -904,10 +990,12 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev) | |||
904 | 990 | ||
905 | return 0; | 991 | return 0; |
906 | 992 | ||
907 | err_init_hw: | ||
908 | err_add_adap: | 993 | err_add_adap: |
909 | clk_put(dev->clk); | 994 | clk_put(dev->clk); |
910 | err_no_clk: | 995 | err_no_clk: |
996 | if (dev->regulator) | ||
997 | regulator_put(dev->regulator); | ||
998 | pm_runtime_disable(&pdev->dev); | ||
911 | free_irq(dev->irq, dev); | 999 | free_irq(dev->irq, dev); |
912 | err_irq: | 1000 | err_irq: |
913 | iounmap(dev->virtbase); | 1001 | iounmap(dev->virtbase); |
@@ -938,6 +1026,9 @@ static int __devexit nmk_i2c_remove(struct platform_device *pdev) | |||
938 | if (res) | 1026 | if (res) |
939 | release_mem_region(res->start, resource_size(res)); | 1027 | release_mem_region(res->start, resource_size(res)); |
940 | clk_put(dev->clk); | 1028 | clk_put(dev->clk); |
1029 | if (dev->regulator) | ||
1030 | regulator_put(dev->regulator); | ||
1031 | pm_runtime_disable(&pdev->dev); | ||
941 | platform_set_drvdata(pdev, NULL); | 1032 | platform_set_drvdata(pdev, NULL); |
942 | kfree(dev); | 1033 | kfree(dev); |
943 | 1034 | ||
@@ -948,6 +1039,7 @@ static struct platform_driver nmk_i2c_driver = { | |||
948 | .driver = { | 1039 | .driver = { |
949 | .owner = THIS_MODULE, | 1040 | .owner = THIS_MODULE, |
950 | .name = DRIVER_NAME, | 1041 | .name = DRIVER_NAME, |
1042 | .pm = &nmk_i2c_pm, | ||
951 | }, | 1043 | }, |
952 | .probe = nmk_i2c_probe, | 1044 | .probe = nmk_i2c_probe, |
953 | .remove = __devexit_p(nmk_i2c_remove), | 1045 | .remove = __devexit_p(nmk_i2c_remove), |
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c index fee1a2613861..1b46a9d9f907 100644 --- a/drivers/i2c/busses/i2c-ocores.c +++ b/drivers/i2c/busses/i2c-ocores.c | |||
@@ -49,7 +49,6 @@ | |||
49 | #include <linux/init.h> | 49 | #include <linux/init.h> |
50 | #include <linux/errno.h> | 50 | #include <linux/errno.h> |
51 | #include <linux/platform_device.h> | 51 | #include <linux/platform_device.h> |
52 | #include <linux/mfd/core.h> | ||
53 | #include <linux/i2c.h> | 52 | #include <linux/i2c.h> |
54 | #include <linux/interrupt.h> | 53 | #include <linux/interrupt.h> |
55 | #include <linux/wait.h> | 54 | #include <linux/wait.h> |
@@ -306,7 +305,7 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev) | |||
306 | return -EIO; | 305 | return -EIO; |
307 | } | 306 | } |
308 | 307 | ||
309 | pdata = mfd_get_data(pdev); | 308 | pdata = pdev->dev.platform_data; |
310 | if (pdata) { | 309 | if (pdata) { |
311 | i2c->regstep = pdata->regstep; | 310 | i2c->regstep = pdata->regstep; |
312 | i2c->clock_khz = pdata->clock_khz; | 311 | i2c->clock_khz = pdata->clock_khz; |
diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c index fc5fbd1012c9..4b95f7a63a3b 100644 --- a/drivers/i2c/busses/i2c-parport-light.c +++ b/drivers/i2c/busses/i2c-parport-light.c | |||
@@ -2,13 +2,13 @@ | |||
2 | * i2c-parport-light.c I2C bus over parallel port * | 2 | * i2c-parport-light.c I2C bus over parallel port * |
3 | * ------------------------------------------------------------------------ * | 3 | * ------------------------------------------------------------------------ * |
4 | Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org> | 4 | Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org> |
5 | 5 | ||
6 | Based on older i2c-velleman.c driver | 6 | Based on older i2c-velleman.c driver |
7 | Copyright (C) 1995-2000 Simon G. Vogl | 7 | Copyright (C) 1995-2000 Simon G. Vogl |
8 | With some changes from: | 8 | With some changes from: |
9 | Frodo Looijaard <frodol@dds.nl> | 9 | Frodo Looijaard <frodol@dds.nl> |
10 | Kyösti Mälkki <kmalkki@cc.hut.fi> | 10 | Kyösti Mälkki <kmalkki@cc.hut.fi> |
11 | 11 | ||
12 | This program is free software; you can redistribute it and/or modify | 12 | This program is free software; you can redistribute it and/or modify |
13 | it under the terms of the GNU General Public License as published by | 13 | it under the terms of the GNU General Public License as published by |
14 | the Free Software Foundation; either version 2 of the License, or | 14 | the Free Software Foundation; either version 2 of the License, or |
@@ -114,7 +114,7 @@ static struct i2c_algo_bit_data parport_algo_data = { | |||
114 | .getscl = parport_getscl, | 114 | .getscl = parport_getscl, |
115 | .udelay = 50, | 115 | .udelay = 50, |
116 | .timeout = HZ, | 116 | .timeout = HZ, |
117 | }; | 117 | }; |
118 | 118 | ||
119 | /* ----- Driver registration ---------------------------------------------- */ | 119 | /* ----- Driver registration ---------------------------------------------- */ |
120 | 120 | ||
@@ -132,7 +132,7 @@ static struct i2c_smbus_alert_setup alert_data = { | |||
132 | static struct i2c_client *ara; | 132 | static struct i2c_client *ara; |
133 | static struct lineop parport_ctrl_irq = { | 133 | static struct lineop parport_ctrl_irq = { |
134 | .val = (1 << 4), | 134 | .val = (1 << 4), |
135 | .port = CTRL, | 135 | .port = PORT_CTRL, |
136 | }; | 136 | }; |
137 | 137 | ||
138 | static int __devinit i2c_parport_probe(struct platform_device *pdev) | 138 | static int __devinit i2c_parport_probe(struct platform_device *pdev) |
@@ -245,7 +245,7 @@ static int __init i2c_parport_init(void) | |||
245 | if (irq != 0) | 245 | if (irq != 0) |
246 | pr_info(DRVNAME ": using irq %d\n", irq); | 246 | pr_info(DRVNAME ": using irq %d\n", irq); |
247 | 247 | ||
248 | if (!adapter_parm[type].getscl.val) | 248 | if (!adapter_parm[type].getscl.val) |
249 | parport_algo_data.getscl = NULL; | 249 | parport_algo_data.getscl = NULL; |
250 | 250 | ||
251 | /* Sets global pdev as a side effect */ | 251 | /* Sets global pdev as a side effect */ |
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index 2dbba163b102..24565687ac9b 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c | |||
@@ -2,13 +2,13 @@ | |||
2 | * i2c-parport.c I2C bus over parallel port * | 2 | * i2c-parport.c I2C bus over parallel port * |
3 | * ------------------------------------------------------------------------ * | 3 | * ------------------------------------------------------------------------ * |
4 | Copyright (C) 2003-2011 Jean Delvare <khali@linux-fr.org> | 4 | Copyright (C) 2003-2011 Jean Delvare <khali@linux-fr.org> |
5 | 5 | ||
6 | Based on older i2c-philips-par.c driver | 6 | Based on older i2c-philips-par.c driver |
7 | Copyright (C) 1995-2000 Simon G. Vogl | 7 | Copyright (C) 1995-2000 Simon G. Vogl |
8 | With some changes from: | 8 | With some changes from: |
9 | Frodo Looijaard <frodol@dds.nl> | 9 | Frodo Looijaard <frodol@dds.nl> |
10 | Kyösti Mälkki <kmalkki@cc.hut.fi> | 10 | Kyösti Mälkki <kmalkki@cc.hut.fi> |
11 | 11 | ||
12 | This program is free software; you can redistribute it and/or modify | 12 | This program is free software; you can redistribute it and/or modify |
13 | it under the terms of the GNU General Public License as published by | 13 | it under the terms of the GNU General Public License as published by |
14 | the Free Software Foundation; either version 2 of the License, or | 14 | the Free Software Foundation; either version 2 of the License, or |
@@ -78,13 +78,13 @@ static unsigned char port_read_control(struct parport *p) | |||
78 | return parport_read_control(p); | 78 | return parport_read_control(p); |
79 | } | 79 | } |
80 | 80 | ||
81 | static void (*port_write[])(struct parport *, unsigned char) = { | 81 | static void (* const port_write[])(struct parport *, unsigned char) = { |
82 | port_write_data, | 82 | port_write_data, |
83 | NULL, | 83 | NULL, |
84 | port_write_control, | 84 | port_write_control, |
85 | }; | 85 | }; |
86 | 86 | ||
87 | static unsigned char (*port_read[])(struct parport *) = { | 87 | static unsigned char (* const port_read[])(struct parport *) = { |
88 | port_read_data, | 88 | port_read_data, |
89 | port_read_status, | 89 | port_read_status, |
90 | port_read_control, | 90 | port_read_control, |
@@ -147,7 +147,7 @@ static const struct i2c_algo_bit_data parport_algo_data = { | |||
147 | .getscl = parport_getscl, | 147 | .getscl = parport_getscl, |
148 | .udelay = 10, /* ~50 kbps */ | 148 | .udelay = 10, /* ~50 kbps */ |
149 | .timeout = HZ, | 149 | .timeout = HZ, |
150 | }; | 150 | }; |
151 | 151 | ||
152 | /* ----- I2c and parallel port call-back functions and structures --------- */ | 152 | /* ----- I2c and parallel port call-back functions and structures --------- */ |
153 | 153 | ||
@@ -164,10 +164,10 @@ void i2c_parport_irq(void *data) | |||
164 | "SMBus alert received but no ARA client!\n"); | 164 | "SMBus alert received but no ARA client!\n"); |
165 | } | 165 | } |
166 | 166 | ||
167 | static void i2c_parport_attach (struct parport *port) | 167 | static void i2c_parport_attach(struct parport *port) |
168 | { | 168 | { |
169 | struct i2c_par *adapter; | 169 | struct i2c_par *adapter; |
170 | 170 | ||
171 | adapter = kzalloc(sizeof(struct i2c_par), GFP_KERNEL); | 171 | adapter = kzalloc(sizeof(struct i2c_par), GFP_KERNEL); |
172 | if (adapter == NULL) { | 172 | if (adapter == NULL) { |
173 | printk(KERN_ERR "i2c-parport: Failed to kzalloc\n"); | 173 | printk(KERN_ERR "i2c-parport: Failed to kzalloc\n"); |
@@ -180,7 +180,7 @@ static void i2c_parport_attach (struct parport *port) | |||
180 | NULL, NULL, i2c_parport_irq, PARPORT_FLAG_EXCL, adapter); | 180 | NULL, NULL, i2c_parport_irq, PARPORT_FLAG_EXCL, adapter); |
181 | if (!adapter->pdev) { | 181 | if (!adapter->pdev) { |
182 | printk(KERN_ERR "i2c-parport: Unable to register with parport\n"); | 182 | printk(KERN_ERR "i2c-parport: Unable to register with parport\n"); |
183 | goto ERROR0; | 183 | goto err_free; |
184 | } | 184 | } |
185 | 185 | ||
186 | /* Fill the rest of the structure */ | 186 | /* Fill the rest of the structure */ |
@@ -200,7 +200,7 @@ static void i2c_parport_attach (struct parport *port) | |||
200 | 200 | ||
201 | if (parport_claim_or_block(adapter->pdev) < 0) { | 201 | if (parport_claim_or_block(adapter->pdev) < 0) { |
202 | printk(KERN_ERR "i2c-parport: Could not claim parallel port\n"); | 202 | printk(KERN_ERR "i2c-parport: Could not claim parallel port\n"); |
203 | goto ERROR1; | 203 | goto err_unregister; |
204 | } | 204 | } |
205 | 205 | ||
206 | /* Reset hardware to a sane state (SCL and SDA high) */ | 206 | /* Reset hardware to a sane state (SCL and SDA high) */ |
@@ -215,7 +215,7 @@ static void i2c_parport_attach (struct parport *port) | |||
215 | 215 | ||
216 | if (i2c_bit_add_bus(&adapter->adapter) < 0) { | 216 | if (i2c_bit_add_bus(&adapter->adapter) < 0) { |
217 | printk(KERN_ERR "i2c-parport: Unable to register with I2C\n"); | 217 | printk(KERN_ERR "i2c-parport: Unable to register with I2C\n"); |
218 | goto ERROR1; | 218 | goto err_unregister; |
219 | } | 219 | } |
220 | 220 | ||
221 | /* Setup SMBus alert if supported */ | 221 | /* Setup SMBus alert if supported */ |
@@ -234,16 +234,16 @@ static void i2c_parport_attach (struct parport *port) | |||
234 | mutex_lock(&adapter_list_lock); | 234 | mutex_lock(&adapter_list_lock); |
235 | list_add_tail(&adapter->node, &adapter_list); | 235 | list_add_tail(&adapter->node, &adapter_list); |
236 | mutex_unlock(&adapter_list_lock); | 236 | mutex_unlock(&adapter_list_lock); |
237 | return; | 237 | return; |
238 | 238 | ||
239 | ERROR1: | 239 | err_unregister: |
240 | parport_release(adapter->pdev); | 240 | parport_release(adapter->pdev); |
241 | parport_unregister_device(adapter->pdev); | 241 | parport_unregister_device(adapter->pdev); |
242 | ERROR0: | 242 | err_free: |
243 | kfree(adapter); | 243 | kfree(adapter); |
244 | } | 244 | } |
245 | 245 | ||
246 | static void i2c_parport_detach (struct parport *port) | 246 | static void i2c_parport_detach(struct parport *port) |
247 | { | 247 | { |
248 | struct i2c_par *adapter, *_n; | 248 | struct i2c_par *adapter, *_n; |
249 | 249 | ||
@@ -260,7 +260,7 @@ static void i2c_parport_detach (struct parport *port) | |||
260 | /* Un-init if needed (power off...) */ | 260 | /* Un-init if needed (power off...) */ |
261 | if (adapter_parm[type].init.val) | 261 | if (adapter_parm[type].init.val) |
262 | line_set(port, 0, &adapter_parm[type].init); | 262 | line_set(port, 0, &adapter_parm[type].init); |
263 | 263 | ||
264 | parport_release(adapter->pdev); | 264 | parport_release(adapter->pdev); |
265 | parport_unregister_device(adapter->pdev); | 265 | parport_unregister_device(adapter->pdev); |
266 | list_del(&adapter->node); | 266 | list_del(&adapter->node); |
diff --git a/drivers/i2c/busses/i2c-parport.h b/drivers/i2c/busses/i2c-parport.h index a9f66816546c..3fe652302ea7 100644 --- a/drivers/i2c/busses/i2c-parport.h +++ b/drivers/i2c/busses/i2c-parport.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * i2c-parport.h I2C bus over parallel port * | 2 | * i2c-parport.h I2C bus over parallel port * |
3 | * ------------------------------------------------------------------------ * | 3 | * ------------------------------------------------------------------------ * |
4 | Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org> | 4 | Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
@@ -18,13 +18,9 @@ | |||
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | * ------------------------------------------------------------------------ */ | 19 | * ------------------------------------------------------------------------ */ |
20 | 20 | ||
21 | #ifdef DATA | 21 | #define PORT_DATA 0 |
22 | #undef DATA | 22 | #define PORT_STAT 1 |
23 | #endif | 23 | #define PORT_CTRL 2 |
24 | |||
25 | #define DATA 0 | ||
26 | #define STAT 1 | ||
27 | #define CTRL 2 | ||
28 | 24 | ||
29 | struct lineop { | 25 | struct lineop { |
30 | u8 val; | 26 | u8 val; |
@@ -41,61 +37,61 @@ struct adapter_parm { | |||
41 | unsigned int smbus_alert:1; | 37 | unsigned int smbus_alert:1; |
42 | }; | 38 | }; |
43 | 39 | ||
44 | static struct adapter_parm adapter_parm[] = { | 40 | static const struct adapter_parm adapter_parm[] = { |
45 | /* type 0: Philips adapter */ | 41 | /* type 0: Philips adapter */ |
46 | { | 42 | { |
47 | .setsda = { 0x80, DATA, 1 }, | 43 | .setsda = { 0x80, PORT_DATA, 1 }, |
48 | .setscl = { 0x08, CTRL, 0 }, | 44 | .setscl = { 0x08, PORT_CTRL, 0 }, |
49 | .getsda = { 0x80, STAT, 0 }, | 45 | .getsda = { 0x80, PORT_STAT, 0 }, |
50 | .getscl = { 0x08, STAT, 0 }, | 46 | .getscl = { 0x08, PORT_STAT, 0 }, |
51 | }, | 47 | }, |
52 | /* type 1: home brew teletext adapter */ | 48 | /* type 1: home brew teletext adapter */ |
53 | { | 49 | { |
54 | .setsda = { 0x02, DATA, 0 }, | 50 | .setsda = { 0x02, PORT_DATA, 0 }, |
55 | .setscl = { 0x01, DATA, 0 }, | 51 | .setscl = { 0x01, PORT_DATA, 0 }, |
56 | .getsda = { 0x80, STAT, 1 }, | 52 | .getsda = { 0x80, PORT_STAT, 1 }, |
57 | }, | 53 | }, |
58 | /* type 2: Velleman K8000 adapter */ | 54 | /* type 2: Velleman K8000 adapter */ |
59 | { | 55 | { |
60 | .setsda = { 0x02, CTRL, 1 }, | 56 | .setsda = { 0x02, PORT_CTRL, 1 }, |
61 | .setscl = { 0x08, CTRL, 1 }, | 57 | .setscl = { 0x08, PORT_CTRL, 1 }, |
62 | .getsda = { 0x10, STAT, 0 }, | 58 | .getsda = { 0x10, PORT_STAT, 0 }, |
63 | }, | 59 | }, |
64 | /* type 3: ELV adapter */ | 60 | /* type 3: ELV adapter */ |
65 | { | 61 | { |
66 | .setsda = { 0x02, DATA, 1 }, | 62 | .setsda = { 0x02, PORT_DATA, 1 }, |
67 | .setscl = { 0x01, DATA, 1 }, | 63 | .setscl = { 0x01, PORT_DATA, 1 }, |
68 | .getsda = { 0x40, STAT, 1 }, | 64 | .getsda = { 0x40, PORT_STAT, 1 }, |
69 | .getscl = { 0x08, STAT, 1 }, | 65 | .getscl = { 0x08, PORT_STAT, 1 }, |
70 | }, | 66 | }, |
71 | /* type 4: ADM1032 evaluation board */ | 67 | /* type 4: ADM1032 evaluation board */ |
72 | { | 68 | { |
73 | .setsda = { 0x02, DATA, 1 }, | 69 | .setsda = { 0x02, PORT_DATA, 1 }, |
74 | .setscl = { 0x01, DATA, 1 }, | 70 | .setscl = { 0x01, PORT_DATA, 1 }, |
75 | .getsda = { 0x10, STAT, 1 }, | 71 | .getsda = { 0x10, PORT_STAT, 1 }, |
76 | .init = { 0xf0, DATA, 0 }, | 72 | .init = { 0xf0, PORT_DATA, 0 }, |
77 | .smbus_alert = 1, | 73 | .smbus_alert = 1, |
78 | }, | 74 | }, |
79 | /* type 5: ADM1025, ADM1030 and ADM1031 evaluation boards */ | 75 | /* type 5: ADM1025, ADM1030 and ADM1031 evaluation boards */ |
80 | { | 76 | { |
81 | .setsda = { 0x02, DATA, 1 }, | 77 | .setsda = { 0x02, PORT_DATA, 1 }, |
82 | .setscl = { 0x01, DATA, 1 }, | 78 | .setscl = { 0x01, PORT_DATA, 1 }, |
83 | .getsda = { 0x10, STAT, 1 }, | 79 | .getsda = { 0x10, PORT_STAT, 1 }, |
84 | }, | 80 | }, |
85 | /* type 6: Barco LPT->DVI (K5800236) adapter */ | 81 | /* type 6: Barco LPT->DVI (K5800236) adapter */ |
86 | { | 82 | { |
87 | .setsda = { 0x02, DATA, 1 }, | 83 | .setsda = { 0x02, PORT_DATA, 1 }, |
88 | .setscl = { 0x01, DATA, 1 }, | 84 | .setscl = { 0x01, PORT_DATA, 1 }, |
89 | .getsda = { 0x20, STAT, 0 }, | 85 | .getsda = { 0x20, PORT_STAT, 0 }, |
90 | .getscl = { 0x40, STAT, 0 }, | 86 | .getscl = { 0x40, PORT_STAT, 0 }, |
91 | .init = { 0xfc, DATA, 0 }, | 87 | .init = { 0xfc, PORT_DATA, 0 }, |
92 | }, | 88 | }, |
93 | /* type 7: One For All JP1 parallel port adapter */ | 89 | /* type 7: One For All JP1 parallel port adapter */ |
94 | { | 90 | { |
95 | .setsda = { 0x01, DATA, 0 }, | 91 | .setsda = { 0x01, PORT_DATA, 0 }, |
96 | .setscl = { 0x02, DATA, 0 }, | 92 | .setscl = { 0x02, PORT_DATA, 0 }, |
97 | .getsda = { 0x80, STAT, 1 }, | 93 | .getsda = { 0x80, PORT_STAT, 1 }, |
98 | .init = { 0x04, DATA, 1 }, | 94 | .init = { 0x04, PORT_DATA, 1 }, |
99 | }, | 95 | }, |
100 | }; | 96 | }; |
101 | 97 | ||
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c index a97e3fec8148..04be9f82e14b 100644 --- a/drivers/i2c/busses/i2c-pnx.c +++ b/drivers/i2c/busses/i2c-pnx.c | |||
@@ -65,7 +65,7 @@ static inline void i2c_pnx_arm_timer(struct i2c_pnx_algo_data *alg_data) | |||
65 | jiffies, expires); | 65 | jiffies, expires); |
66 | 66 | ||
67 | timer->expires = jiffies + expires; | 67 | timer->expires = jiffies + expires; |
68 | timer->data = (unsigned long)&alg_data; | 68 | timer->data = (unsigned long)alg_data; |
69 | 69 | ||
70 | add_timer(timer); | 70 | add_timer(timer); |
71 | } | 71 | } |
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 2707f5e17158..f633a53b6dbe 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/clk.h> | 32 | #include <linux/clk.h> |
33 | #include <linux/io.h> | 33 | #include <linux/io.h> |
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <linux/i2c/i2c-sh_mobile.h> | ||
35 | 36 | ||
36 | /* Transmit operation: */ | 37 | /* Transmit operation: */ |
37 | /* */ | 38 | /* */ |
@@ -117,7 +118,7 @@ struct sh_mobile_i2c_data { | |||
117 | struct device *dev; | 118 | struct device *dev; |
118 | void __iomem *reg; | 119 | void __iomem *reg; |
119 | struct i2c_adapter adap; | 120 | struct i2c_adapter adap; |
120 | 121 | unsigned long bus_speed; | |
121 | struct clk *clk; | 122 | struct clk *clk; |
122 | u_int8_t icic; | 123 | u_int8_t icic; |
123 | u_int8_t iccl; | 124 | u_int8_t iccl; |
@@ -205,7 +206,7 @@ static void activate_ch(struct sh_mobile_i2c_data *pd) | |||
205 | * We also round off the result. | 206 | * We also round off the result. |
206 | */ | 207 | */ |
207 | num = i2c_clk * 5; | 208 | num = i2c_clk * 5; |
208 | denom = NORMAL_SPEED * 9; | 209 | denom = pd->bus_speed * 9; |
209 | tmp = num * 10 / denom; | 210 | tmp = num * 10 / denom; |
210 | if (tmp % 10 >= 5) | 211 | if (tmp % 10 >= 5) |
211 | pd->iccl = (u_int8_t)((num/denom) + 1); | 212 | pd->iccl = (u_int8_t)((num/denom) + 1); |
@@ -574,10 +575,10 @@ static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, int hook) | |||
574 | 575 | ||
575 | static int sh_mobile_i2c_probe(struct platform_device *dev) | 576 | static int sh_mobile_i2c_probe(struct platform_device *dev) |
576 | { | 577 | { |
578 | struct i2c_sh_mobile_platform_data *pdata = dev->dev.platform_data; | ||
577 | struct sh_mobile_i2c_data *pd; | 579 | struct sh_mobile_i2c_data *pd; |
578 | struct i2c_adapter *adap; | 580 | struct i2c_adapter *adap; |
579 | struct resource *res; | 581 | struct resource *res; |
580 | char clk_name[8]; | ||
581 | int size; | 582 | int size; |
582 | int ret; | 583 | int ret; |
583 | 584 | ||
@@ -587,10 +588,9 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) | |||
587 | return -ENOMEM; | 588 | return -ENOMEM; |
588 | } | 589 | } |
589 | 590 | ||
590 | snprintf(clk_name, sizeof(clk_name), "i2c%d", dev->id); | 591 | pd->clk = clk_get(&dev->dev, NULL); |
591 | pd->clk = clk_get(&dev->dev, clk_name); | ||
592 | if (IS_ERR(pd->clk)) { | 592 | if (IS_ERR(pd->clk)) { |
593 | dev_err(&dev->dev, "cannot get clock \"%s\"\n", clk_name); | 593 | dev_err(&dev->dev, "cannot get clock\n"); |
594 | ret = PTR_ERR(pd->clk); | 594 | ret = PTR_ERR(pd->clk); |
595 | goto err; | 595 | goto err; |
596 | } | 596 | } |
@@ -620,6 +620,11 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) | |||
620 | goto err_irq; | 620 | goto err_irq; |
621 | } | 621 | } |
622 | 622 | ||
623 | /* Use platformd data bus speed or NORMAL_SPEED */ | ||
624 | pd->bus_speed = NORMAL_SPEED; | ||
625 | if (pdata && pdata->bus_speed) | ||
626 | pd->bus_speed = pdata->bus_speed; | ||
627 | |||
623 | /* The IIC blocks on SH-Mobile ARM processors | 628 | /* The IIC blocks on SH-Mobile ARM processors |
624 | * come with two new bits in ICIC. | 629 | * come with two new bits in ICIC. |
625 | */ | 630 | */ |
@@ -660,6 +665,8 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) | |||
660 | goto err_all; | 665 | goto err_all; |
661 | } | 666 | } |
662 | 667 | ||
668 | dev_info(&dev->dev, "I2C adapter %d with bus speed %lu Hz\n", | ||
669 | adap->nr, pd->bus_speed); | ||
663 | return 0; | 670 | return 0; |
664 | 671 | ||
665 | err_all: | 672 | err_all: |
@@ -729,3 +736,4 @@ module_exit(sh_mobile_i2c_adap_exit); | |||
729 | MODULE_DESCRIPTION("SuperH Mobile I2C Bus Controller driver"); | 736 | MODULE_DESCRIPTION("SuperH Mobile I2C Bus Controller driver"); |
730 | MODULE_AUTHOR("Magnus Damm"); | 737 | MODULE_AUTHOR("Magnus Damm"); |
731 | MODULE_LICENSE("GPL v2"); | 738 | MODULE_LICENSE("GPL v2"); |
739 | MODULE_ALIAS("platform:i2c-sh_mobile"); | ||
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index b4ab39b741eb..4d9319665e32 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c | |||
@@ -35,8 +35,10 @@ | |||
35 | #define BYTES_PER_FIFO_WORD 4 | 35 | #define BYTES_PER_FIFO_WORD 4 |
36 | 36 | ||
37 | #define I2C_CNFG 0x000 | 37 | #define I2C_CNFG 0x000 |
38 | #define I2C_CNFG_DEBOUNCE_CNT_SHIFT 12 | ||
38 | #define I2C_CNFG_PACKET_MODE_EN (1<<10) | 39 | #define I2C_CNFG_PACKET_MODE_EN (1<<10) |
39 | #define I2C_CNFG_NEW_MASTER_FSM (1<<11) | 40 | #define I2C_CNFG_NEW_MASTER_FSM (1<<11) |
41 | #define I2C_STATUS 0x01C | ||
40 | #define I2C_SL_CNFG 0x020 | 42 | #define I2C_SL_CNFG 0x020 |
41 | #define I2C_SL_CNFG_NEWSL (1<<2) | 43 | #define I2C_SL_CNFG_NEWSL (1<<2) |
42 | #define I2C_SL_ADDR1 0x02c | 44 | #define I2C_SL_ADDR1 0x02c |
@@ -77,6 +79,7 @@ | |||
77 | #define I2C_ERR_NONE 0x00 | 79 | #define I2C_ERR_NONE 0x00 |
78 | #define I2C_ERR_NO_ACK 0x01 | 80 | #define I2C_ERR_NO_ACK 0x01 |
79 | #define I2C_ERR_ARBITRATION_LOST 0x02 | 81 | #define I2C_ERR_ARBITRATION_LOST 0x02 |
82 | #define I2C_ERR_UNKNOWN_INTERRUPT 0x04 | ||
80 | 83 | ||
81 | #define PACKET_HEADER0_HEADER_SIZE_SHIFT 28 | 84 | #define PACKET_HEADER0_HEADER_SIZE_SHIFT 28 |
82 | #define PACKET_HEADER0_PACKET_ID_SHIFT 16 | 85 | #define PACKET_HEADER0_PACKET_ID_SHIFT 16 |
@@ -121,6 +124,7 @@ struct tegra_i2c_dev { | |||
121 | void __iomem *base; | 124 | void __iomem *base; |
122 | int cont_id; | 125 | int cont_id; |
123 | int irq; | 126 | int irq; |
127 | bool irq_disabled; | ||
124 | int is_dvc; | 128 | int is_dvc; |
125 | struct completion msg_complete; | 129 | struct completion msg_complete; |
126 | int msg_err; | 130 | int msg_err; |
@@ -325,11 +329,17 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) | |||
325 | if (i2c_dev->is_dvc) | 329 | if (i2c_dev->is_dvc) |
326 | tegra_dvc_init(i2c_dev); | 330 | tegra_dvc_init(i2c_dev); |
327 | 331 | ||
328 | val = I2C_CNFG_NEW_MASTER_FSM | I2C_CNFG_PACKET_MODE_EN; | 332 | val = I2C_CNFG_NEW_MASTER_FSM | I2C_CNFG_PACKET_MODE_EN | |
333 | (0x2 << I2C_CNFG_DEBOUNCE_CNT_SHIFT); | ||
329 | i2c_writel(i2c_dev, val, I2C_CNFG); | 334 | i2c_writel(i2c_dev, val, I2C_CNFG); |
330 | i2c_writel(i2c_dev, 0, I2C_INT_MASK); | 335 | i2c_writel(i2c_dev, 0, I2C_INT_MASK); |
331 | clk_set_rate(i2c_dev->clk, i2c_dev->bus_clk_rate * 8); | 336 | clk_set_rate(i2c_dev->clk, i2c_dev->bus_clk_rate * 8); |
332 | 337 | ||
338 | if (!i2c_dev->is_dvc) { | ||
339 | u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG); | ||
340 | i2c_writel(i2c_dev, sl_cfg | I2C_SL_CNFG_NEWSL, I2C_SL_CNFG); | ||
341 | } | ||
342 | |||
333 | val = 7 << I2C_FIFO_CONTROL_TX_TRIG_SHIFT | | 343 | val = 7 << I2C_FIFO_CONTROL_TX_TRIG_SHIFT | |
334 | 0 << I2C_FIFO_CONTROL_RX_TRIG_SHIFT; | 344 | 0 << I2C_FIFO_CONTROL_RX_TRIG_SHIFT; |
335 | i2c_writel(i2c_dev, val, I2C_FIFO_CONTROL); | 345 | i2c_writel(i2c_dev, val, I2C_FIFO_CONTROL); |
@@ -338,6 +348,12 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) | |||
338 | err = -ETIMEDOUT; | 348 | err = -ETIMEDOUT; |
339 | 349 | ||
340 | clk_disable(i2c_dev->clk); | 350 | clk_disable(i2c_dev->clk); |
351 | |||
352 | if (i2c_dev->irq_disabled) { | ||
353 | i2c_dev->irq_disabled = 0; | ||
354 | enable_irq(i2c_dev->irq); | ||
355 | } | ||
356 | |||
341 | return err; | 357 | return err; |
342 | } | 358 | } |
343 | 359 | ||
@@ -350,8 +366,19 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id) | |||
350 | status = i2c_readl(i2c_dev, I2C_INT_STATUS); | 366 | status = i2c_readl(i2c_dev, I2C_INT_STATUS); |
351 | 367 | ||
352 | if (status == 0) { | 368 | if (status == 0) { |
353 | dev_warn(i2c_dev->dev, "interrupt with no status\n"); | 369 | dev_warn(i2c_dev->dev, "irq status 0 %08x %08x %08x\n", |
354 | return IRQ_NONE; | 370 | i2c_readl(i2c_dev, I2C_PACKET_TRANSFER_STATUS), |
371 | i2c_readl(i2c_dev, I2C_STATUS), | ||
372 | i2c_readl(i2c_dev, I2C_CNFG)); | ||
373 | i2c_dev->msg_err |= I2C_ERR_UNKNOWN_INTERRUPT; | ||
374 | |||
375 | if (!i2c_dev->irq_disabled) { | ||
376 | disable_irq_nosync(i2c_dev->irq); | ||
377 | i2c_dev->irq_disabled = 1; | ||
378 | } | ||
379 | |||
380 | complete(&i2c_dev->msg_complete); | ||
381 | goto err; | ||
355 | } | 382 | } |
356 | 383 | ||
357 | if (unlikely(status & status_err)) { | 384 | if (unlikely(status & status_err)) { |
@@ -391,6 +418,8 @@ err: | |||
391 | I2C_INT_PACKET_XFER_COMPLETE | I2C_INT_TX_FIFO_DATA_REQ | | 418 | I2C_INT_PACKET_XFER_COMPLETE | I2C_INT_TX_FIFO_DATA_REQ | |
392 | I2C_INT_RX_FIFO_DATA_REQ); | 419 | I2C_INT_RX_FIFO_DATA_REQ); |
393 | i2c_writel(i2c_dev, status, I2C_INT_STATUS); | 420 | i2c_writel(i2c_dev, status, I2C_INT_STATUS); |
421 | if (i2c_dev->is_dvc) | ||
422 | dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS); | ||
394 | return IRQ_HANDLED; | 423 | return IRQ_HANDLED; |
395 | } | 424 | } |
396 | 425 | ||
@@ -424,12 +453,12 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, | |||
424 | 453 | ||
425 | packet_header = msg->addr << I2C_HEADER_SLAVE_ADDR_SHIFT; | 454 | packet_header = msg->addr << I2C_HEADER_SLAVE_ADDR_SHIFT; |
426 | packet_header |= I2C_HEADER_IE_ENABLE; | 455 | packet_header |= I2C_HEADER_IE_ENABLE; |
456 | if (!stop) | ||
457 | packet_header |= I2C_HEADER_REPEAT_START; | ||
427 | if (msg->flags & I2C_M_TEN) | 458 | if (msg->flags & I2C_M_TEN) |
428 | packet_header |= I2C_HEADER_10BIT_ADDR; | 459 | packet_header |= I2C_HEADER_10BIT_ADDR; |
429 | if (msg->flags & I2C_M_IGNORE_NAK) | 460 | if (msg->flags & I2C_M_IGNORE_NAK) |
430 | packet_header |= I2C_HEADER_CONT_ON_NAK; | 461 | packet_header |= I2C_HEADER_CONT_ON_NAK; |
431 | if (msg->flags & I2C_M_NOSTART) | ||
432 | packet_header |= I2C_HEADER_REPEAT_START; | ||
433 | if (msg->flags & I2C_M_RD) | 462 | if (msg->flags & I2C_M_RD) |
434 | packet_header |= I2C_HEADER_READ; | 463 | packet_header |= I2C_HEADER_READ; |
435 | i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); | 464 | i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); |
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index e9d5ff4d1496..4bb68f35caf2 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/platform_device.h> | 36 | #include <linux/platform_device.h> |
37 | #include <linux/mfd/core.h> | ||
38 | #include <linux/i2c.h> | 37 | #include <linux/i2c.h> |
39 | #include <linux/interrupt.h> | 38 | #include <linux/interrupt.h> |
40 | #include <linux/wait.h> | 39 | #include <linux/wait.h> |
@@ -705,7 +704,7 @@ static int __devinit xiic_i2c_probe(struct platform_device *pdev) | |||
705 | if (irq < 0) | 704 | if (irq < 0) |
706 | goto resource_missing; | 705 | goto resource_missing; |
707 | 706 | ||
708 | pdata = mfd_get_data(pdev); | 707 | pdata = (struct xiic_i2c_platform_data *) pdev->dev.platform_data; |
709 | if (!pdata) | 708 | if (!pdata) |
710 | return -EINVAL; | 709 | return -EINVAL; |
711 | 710 | ||