aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/i2c/nomadik.txt23
-rw-r--r--drivers/i2c/busses/i2c-nomadik.c35
-rw-r--r--include/linux/platform_data/i2c-nomadik.h2
3 files changed, 56 insertions, 4 deletions
diff --git a/Documentation/devicetree/bindings/i2c/nomadik.txt b/Documentation/devicetree/bindings/i2c/nomadik.txt
new file mode 100644
index 000000000000..72065b0ff680
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/nomadik.txt
@@ -0,0 +1,23 @@
1I2C for Nomadik based systems
2
3Required (non-standard) properties:
4 - Nil
5
6Recommended (non-standard) properties:
7 - clock-frequency : Maximum bus clock frequency for the device
8
9Optional (non-standard) properties:
10 - Nil
11
12Example :
13
14i2c@80004000 {
15 compatible = "stericsson,db8500-i2c", "st,nomadik-i2c";
16 reg = <0x80004000 0x1000>;
17 interrupts = <0 21 0x4>;
18 #address-cells = <1>;
19 #size-cells = <0>;
20 v-i2c-supply = <&db8500_vape_reg>;
21
22 clock-frequency = <400000>;
23};
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 1b898b647ec2..698d7acb0f08 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -24,6 +24,8 @@
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/pm_runtime.h> 25#include <linux/pm_runtime.h>
26#include <linux/platform_data/i2c-nomadik.h> 26#include <linux/platform_data/i2c-nomadik.h>
27#include <linux/of.h>
28#include <linux/of_i2c.h>
27 29
28#define DRIVER_NAME "nmk-i2c" 30#define DRIVER_NAME "nmk-i2c"
29 31
@@ -913,18 +915,42 @@ static struct nmk_i2c_controller u8500_i2c = {
913 .sm = I2C_FREQ_MODE_FAST, 915 .sm = I2C_FREQ_MODE_FAST,
914}; 916};
915 917
918static void nmk_i2c_of_probe(struct device_node *np,
919 struct nmk_i2c_controller *pdata)
920{
921 of_property_read_u32(np, "clock-frequency", &pdata->clk_freq);
922
923 /* This driver only supports 'standard' and 'fast' modes of operation. */
924 if (pdata->clk_freq <= 100000)
925 pdata->sm = I2C_FREQ_MODE_STANDARD;
926 else
927 pdata->sm = I2C_FREQ_MODE_FAST;
928}
929
916static atomic_t adapter_id = ATOMIC_INIT(0); 930static atomic_t adapter_id = ATOMIC_INIT(0);
917 931
918static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) 932static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
919{ 933{
920 int ret = 0; 934 int ret = 0;
921 struct nmk_i2c_controller *pdata = adev->dev.platform_data; 935 struct nmk_i2c_controller *pdata = adev->dev.platform_data;
936 struct device_node *np = adev->dev.of_node;
922 struct nmk_i2c_dev *dev; 937 struct nmk_i2c_dev *dev;
923 struct i2c_adapter *adap; 938 struct i2c_adapter *adap;
924 939
925 if (!pdata) 940 if (!pdata) {
926 /* No i2c configuration found, using the default. */ 941 if (np) {
927 pdata = &u8500_i2c; 942 pdata = devm_kzalloc(&adev->dev, sizeof(*pdata), GFP_KERNEL);
943 if (!pdata) {
944 ret = -ENOMEM;
945 goto err_no_mem;
946 }
947 /* Provide the default configuration as a base. */
948 memcpy(pdata, &u8500_i2c, sizeof(struct nmk_i2c_controller));
949 nmk_i2c_of_probe(np, pdata);
950 } else
951 /* No i2c configuration found, using the default. */
952 pdata = &u8500_i2c;
953 }
928 954
929 dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL); 955 dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL);
930 if (!dev) { 956 if (!dev) {
@@ -960,6 +986,7 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
960 } 986 }
961 987
962 adap = &dev->adap; 988 adap = &dev->adap;
989 adap->dev.of_node = np;
963 adap->dev.parent = &adev->dev; 990 adap->dev.parent = &adev->dev;
964 adap->owner = THIS_MODULE; 991 adap->owner = THIS_MODULE;
965 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 992 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
@@ -989,6 +1016,8 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
989 goto err_add_adap; 1016 goto err_add_adap;
990 } 1017 }
991 1018
1019 of_i2c_register_devices(adap);
1020
992 pm_runtime_put(&adev->dev); 1021 pm_runtime_put(&adev->dev);
993 1022
994 return 0; 1023 return 0;
diff --git a/include/linux/platform_data/i2c-nomadik.h b/include/linux/platform_data/i2c-nomadik.h
index c2303c3e4803..3a8be9cdc95c 100644
--- a/include/linux/platform_data/i2c-nomadik.h
+++ b/include/linux/platform_data/i2c-nomadik.h
@@ -28,7 +28,7 @@ enum i2c_freq_mode {
28 * @sm: speed mode 28 * @sm: speed mode
29 */ 29 */
30struct nmk_i2c_controller { 30struct nmk_i2c_controller {
31 unsigned long clk_freq; 31 u32 clk_freq;
32 unsigned short slsu; 32 unsigned short slsu;
33 unsigned char tft; 33 unsigned char tft;
34 unsigned char rft; 34 unsigned char rft;