diff options
Diffstat (limited to 'arch/arm/plat-omap/i2c.c')
-rw-r--r-- | arch/arm/plat-omap/i2c.c | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c index 624e26298faa..f044b5927508 100644 --- a/arch/arm/plat-omap/i2c.c +++ b/arch/arm/plat-omap/i2c.c | |||
@@ -26,9 +26,12 @@ | |||
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/i2c-omap.h> | ||
30 | |||
29 | #include <mach/irqs.h> | 31 | #include <mach/irqs.h> |
30 | #include <plat/mux.h> | 32 | #include <plat/mux.h> |
31 | #include <plat/i2c.h> | 33 | #include <plat/i2c.h> |
34 | #include <plat/omap-pm.h> | ||
32 | 35 | ||
33 | #define OMAP_I2C_SIZE 0x3f | 36 | #define OMAP_I2C_SIZE 0x3f |
34 | #define OMAP1_I2C_BASE 0xfffb3800 | 37 | #define OMAP1_I2C_BASE 0xfffb3800 |
@@ -70,14 +73,14 @@ static struct resource i2c_resources[][2] = { | |||
70 | }, \ | 73 | }, \ |
71 | } | 74 | } |
72 | 75 | ||
73 | static u32 i2c_rate[ARRAY_SIZE(i2c_resources)]; | 76 | static struct omap_i2c_bus_platform_data i2c_pdata[ARRAY_SIZE(i2c_resources)]; |
74 | static struct platform_device omap_i2c_devices[] = { | 77 | static struct platform_device omap_i2c_devices[] = { |
75 | I2C_DEV_BUILDER(1, i2c_resources[0], &i2c_rate[0]), | 78 | I2C_DEV_BUILDER(1, i2c_resources[0], &i2c_pdata[0]), |
76 | #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) | 79 | #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) |
77 | I2C_DEV_BUILDER(2, i2c_resources[1], &i2c_rate[1]), | 80 | I2C_DEV_BUILDER(2, i2c_resources[1], &i2c_pdata[1]), |
78 | #endif | 81 | #endif |
79 | #if defined(CONFIG_ARCH_OMAP3) | 82 | #if defined(CONFIG_ARCH_OMAP3) |
80 | I2C_DEV_BUILDER(3, i2c_resources[2], &i2c_rate[2]), | 83 | I2C_DEV_BUILDER(3, i2c_resources[2], &i2c_pdata[2]), |
81 | #endif | 84 | #endif |
82 | }; | 85 | }; |
83 | 86 | ||
@@ -100,10 +103,12 @@ static int __init omap_i2c_nr_ports(void) | |||
100 | static int __init omap_i2c_add_bus(int bus_id) | 103 | static int __init omap_i2c_add_bus(int bus_id) |
101 | { | 104 | { |
102 | struct platform_device *pdev; | 105 | struct platform_device *pdev; |
106 | struct omap_i2c_bus_platform_data *pd; | ||
103 | struct resource *res; | 107 | struct resource *res; |
104 | resource_size_t base, irq; | 108 | resource_size_t base, irq; |
105 | 109 | ||
106 | pdev = &omap_i2c_devices[bus_id - 1]; | 110 | pdev = &omap_i2c_devices[bus_id - 1]; |
111 | pd = pdev->dev.platform_data; | ||
107 | if (bus_id == 1) { | 112 | if (bus_id == 1) { |
108 | res = pdev->resource; | 113 | res = pdev->resource; |
109 | if (cpu_class_is_omap1()) { | 114 | if (cpu_class_is_omap1()) { |
@@ -123,6 +128,15 @@ static int __init omap_i2c_add_bus(int bus_id) | |||
123 | if (cpu_class_is_omap2()) | 128 | if (cpu_class_is_omap2()) |
124 | omap2_i2c_mux_pins(bus_id); | 129 | omap2_i2c_mux_pins(bus_id); |
125 | 130 | ||
131 | /* | ||
132 | * When waiting for completion of a i2c transfer, we need to | ||
133 | * set a wake up latency constraint for the MPU. This is to | ||
134 | * ensure quick enough wakeup from idle, when transfer | ||
135 | * completes. | ||
136 | */ | ||
137 | if (cpu_is_omap34xx()) | ||
138 | pd->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat; | ||
139 | |||
126 | return platform_device_register(pdev); | 140 | return platform_device_register(pdev); |
127 | } | 141 | } |
128 | 142 | ||
@@ -146,8 +160,8 @@ static int __init omap_i2c_bus_setup(char *str) | |||
146 | get_options(str, 3, ints); | 160 | get_options(str, 3, ints); |
147 | if (ints[0] < 2 || ints[1] < 1 || ints[1] > ports) | 161 | if (ints[0] < 2 || ints[1] < 1 || ints[1] > ports) |
148 | return 0; | 162 | return 0; |
149 | i2c_rate[ints[1] - 1] = ints[2]; | 163 | i2c_pdata[ints[1] - 1].clkrate = ints[2]; |
150 | i2c_rate[ints[1] - 1] |= OMAP_I2C_CMDLINE_SETUP; | 164 | i2c_pdata[ints[1] - 1].clkrate |= OMAP_I2C_CMDLINE_SETUP; |
151 | 165 | ||
152 | return 1; | 166 | return 1; |
153 | } | 167 | } |
@@ -161,9 +175,9 @@ static int __init omap_register_i2c_bus_cmdline(void) | |||
161 | { | 175 | { |
162 | int i, err = 0; | 176 | int i, err = 0; |
163 | 177 | ||
164 | for (i = 0; i < ARRAY_SIZE(i2c_rate); i++) | 178 | for (i = 0; i < ARRAY_SIZE(i2c_pdata); i++) |
165 | if (i2c_rate[i] & OMAP_I2C_CMDLINE_SETUP) { | 179 | if (i2c_pdata[i].clkrate & OMAP_I2C_CMDLINE_SETUP) { |
166 | i2c_rate[i] &= ~OMAP_I2C_CMDLINE_SETUP; | 180 | i2c_pdata[i].clkrate &= ~OMAP_I2C_CMDLINE_SETUP; |
167 | err = omap_i2c_add_bus(i + 1); | 181 | err = omap_i2c_add_bus(i + 1); |
168 | if (err) | 182 | if (err) |
169 | goto out; | 183 | goto out; |
@@ -197,9 +211,10 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate, | |||
197 | return err; | 211 | return err; |
198 | } | 212 | } |
199 | 213 | ||
200 | if (!i2c_rate[bus_id - 1]) | 214 | if (!i2c_pdata[bus_id - 1].clkrate) |
201 | i2c_rate[bus_id - 1] = clkrate; | 215 | i2c_pdata[bus_id - 1].clkrate = clkrate; |
202 | i2c_rate[bus_id - 1] &= ~OMAP_I2C_CMDLINE_SETUP; | 216 | |
217 | i2c_pdata[bus_id - 1].clkrate &= ~OMAP_I2C_CMDLINE_SETUP; | ||
203 | 218 | ||
204 | return omap_i2c_add_bus(bus_id); | 219 | return omap_i2c_add_bus(bus_id); |
205 | } | 220 | } |