diff options
author | Tony Lindgren <tony@atomide.com> | 2010-05-20 14:36:43 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2010-05-20 14:36:43 -0400 |
commit | b32dd41ed645c22ac3ce4e25bcbd7eee30297292 (patch) | |
tree | 6a1724615611ca78effc76cdce1f9ecd44b4dfc3 /arch/arm | |
parent | 20c9d2c4ab8243a1c311248232954b2c1da3ba75 (diff) |
omap: Fix i2c platform init code for omap4
Add separate omap_i2c_add_bus functions for mach-omap1
and mach-omap2. Make the mach-omap2 init set the interrupt
dynamically to support.
This is needed to add support for omap4 in a way that
works with multi-omap builds. This will eventually get
fixed in a generic way with the omap hwmods.
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/plat-omap/i2c.c | 67 |
1 files changed, 47 insertions, 20 deletions
diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c index f044b5927508..78d1cea9118d 100644 --- a/arch/arm/plat-omap/i2c.c +++ b/arch/arm/plat-omap/i2c.c | |||
@@ -100,33 +100,44 @@ static int __init omap_i2c_nr_ports(void) | |||
100 | return ports; | 100 | return ports; |
101 | } | 101 | } |
102 | 102 | ||
103 | static int __init omap_i2c_add_bus(int bus_id) | 103 | /* Shared between omap2 and 3 */ |
104 | static resource_size_t omap2_i2c_irq[3] __initdata = { | ||
105 | INT_24XX_I2C1_IRQ, | ||
106 | INT_24XX_I2C2_IRQ, | ||
107 | INT_34XX_I2C3_IRQ, | ||
108 | }; | ||
109 | |||
110 | static inline int omap1_i2c_add_bus(struct platform_device *pdev, int bus_id) | ||
104 | { | 111 | { |
105 | struct platform_device *pdev; | ||
106 | struct omap_i2c_bus_platform_data *pd; | 112 | struct omap_i2c_bus_platform_data *pd; |
107 | struct resource *res; | 113 | struct resource *res; |
108 | resource_size_t base, irq; | ||
109 | 114 | ||
110 | pdev = &omap_i2c_devices[bus_id - 1]; | ||
111 | pd = pdev->dev.platform_data; | 115 | pd = pdev->dev.platform_data; |
116 | res = pdev->resource; | ||
117 | res[0].start = OMAP1_I2C_BASE; | ||
118 | res[0].end = res[0].start + OMAP_I2C_SIZE; | ||
119 | res[1].start = INT_I2C; | ||
120 | omap1_i2c_mux_pins(bus_id); | ||
121 | |||
122 | return platform_device_register(pdev); | ||
123 | } | ||
124 | |||
125 | static inline int omap2_i2c_add_bus(struct platform_device *pdev, int bus_id) | ||
126 | { | ||
127 | struct resource *res; | ||
128 | resource_size_t *irq; | ||
129 | |||
130 | res = pdev->resource; | ||
131 | |||
132 | irq = omap2_i2c_irq; | ||
133 | |||
112 | if (bus_id == 1) { | 134 | if (bus_id == 1) { |
113 | res = pdev->resource; | 135 | res[0].start = OMAP2_I2C_BASE1; |
114 | if (cpu_class_is_omap1()) { | 136 | res[0].end = res[0].start + OMAP_I2C_SIZE; |
115 | base = OMAP1_I2C_BASE; | ||
116 | irq = INT_I2C; | ||
117 | } else { | ||
118 | base = OMAP2_I2C_BASE1; | ||
119 | irq = INT_24XX_I2C1_IRQ; | ||
120 | } | ||
121 | res[0].start = base; | ||
122 | res[0].end = base + OMAP_I2C_SIZE; | ||
123 | res[1].start = irq; | ||
124 | } | 137 | } |
125 | 138 | ||
126 | if (cpu_class_is_omap1()) | 139 | res[1].start = irq[bus_id - 1]; |
127 | omap1_i2c_mux_pins(bus_id); | 140 | omap2_i2c_mux_pins(bus_id); |
128 | if (cpu_class_is_omap2()) | ||
129 | omap2_i2c_mux_pins(bus_id); | ||
130 | 141 | ||
131 | /* | 142 | /* |
132 | * When waiting for completion of a i2c transfer, we need to | 143 | * When waiting for completion of a i2c transfer, we need to |
@@ -134,12 +145,28 @@ static int __init omap_i2c_add_bus(int bus_id) | |||
134 | * ensure quick enough wakeup from idle, when transfer | 145 | * ensure quick enough wakeup from idle, when transfer |
135 | * completes. | 146 | * completes. |
136 | */ | 147 | */ |
137 | if (cpu_is_omap34xx()) | 148 | if (cpu_is_omap34xx()) { |
149 | struct omap_i2c_bus_platform_data *pd; | ||
150 | |||
151 | pd = pdev->dev.platform_data; | ||
138 | pd->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat; | 152 | pd->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat; |
153 | } | ||
139 | 154 | ||
140 | return platform_device_register(pdev); | 155 | return platform_device_register(pdev); |
141 | } | 156 | } |
142 | 157 | ||
158 | static int __init omap_i2c_add_bus(int bus_id) | ||
159 | { | ||
160 | struct platform_device *pdev; | ||
161 | |||
162 | pdev = &omap_i2c_devices[bus_id - 1]; | ||
163 | |||
164 | if (cpu_class_is_omap1()) | ||
165 | return omap1_i2c_add_bus(pdev, bus_id); | ||
166 | else | ||
167 | return omap2_i2c_add_bus(pdev, bus_id); | ||
168 | } | ||
169 | |||
143 | /** | 170 | /** |
144 | * omap_i2c_bus_setup - Process command line options for the I2C bus speed | 171 | * omap_i2c_bus_setup - Process command line options for the I2C bus speed |
145 | * @str: String of options | 172 | * @str: String of options |