aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/cavium-octeon
diff options
context:
space:
mode:
authorDavid Daney <david.daney@cavium.com>2012-07-05 12:12:39 -0400
committerRalf Baechle <ralf@linux-mips.org>2012-07-23 08:54:53 -0400
commitf353a218de6393fb43a5e81c3adbe1aac1a871ab (patch)
tree2b005cd034b91c66f452b3a030373049edacce08 /arch/mips/cavium-octeon
parenta0c16582b5b50792b0fd3e07d23c537936fafcb7 (diff)
i2c: Convert i2c-octeon.c to use device tree.
There are three parts to this: 1) Remove the definitions of OCTEON_IRQ_TWSI and OCTEON_IRQ_TWSI2. The interrupts are specified by the device tree and these hard coded irq numbers block the used of the irq lines by the irq_domain code. 2) Remove platform device setup code from octeon-platform.c, it is now unused. 3) Convert i2c-octeon.c to use device tree. Part of this includes using the devm_* functions instead of the raw counterparts, thus simplifying error handling. No functionality is changed. Signed-off-by: David Daney <david.daney@cavium.com> Acked-by: Rob Herring <rob.herring@calxeda.com> Acked-by: Wolfram Sang <w.sang@pengutronix.de> Cc: linux-mips@linux-mips.org Cc: devicetree-discuss@lists.ozlabs.org Cc: Grant Likely <grant.likely@secretlab.ca> Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/3939/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/cavium-octeon')
-rw-r--r--arch/mips/cavium-octeon/octeon-irq.c2
-rw-r--r--arch/mips/cavium-octeon/octeon-platform.c84
2 files changed, 0 insertions, 86 deletions
diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c
index 52610ce50dfc..2a661ad35cf7 100644
--- a/arch/mips/cavium-octeon/octeon-irq.c
+++ b/arch/mips/cavium-octeon/octeon-irq.c
@@ -1192,13 +1192,11 @@ static void __init octeon_irq_init_ciu(void)
1192 for (i = 0; i < 4; i++) 1192 for (i = 0; i < 4; i++)
1193 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_PCI_MSI0, 0, i + 40, chip, handle_level_irq); 1193 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_PCI_MSI0, 0, i + 40, chip, handle_level_irq);
1194 1194
1195 octeon_irq_set_ciu_mapping(OCTEON_IRQ_TWSI, 0, 45, chip, handle_level_irq);
1196 octeon_irq_set_ciu_mapping(OCTEON_IRQ_RML, 0, 46, chip, handle_level_irq); 1195 octeon_irq_set_ciu_mapping(OCTEON_IRQ_RML, 0, 46, chip, handle_level_irq);
1197 for (i = 0; i < 4; i++) 1196 for (i = 0; i < 4; i++)
1198 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_TIMER0, 0, i + 52, chip, handle_edge_irq); 1197 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_TIMER0, 0, i + 52, chip, handle_edge_irq);
1199 1198
1200 octeon_irq_set_ciu_mapping(OCTEON_IRQ_USB0, 0, 56, chip, handle_level_irq); 1199 octeon_irq_set_ciu_mapping(OCTEON_IRQ_USB0, 0, 56, chip, handle_level_irq);
1201 octeon_irq_set_ciu_mapping(OCTEON_IRQ_TWSI2, 0, 59, chip, handle_level_irq);
1202 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MII0, 0, 62, chip, handle_level_irq); 1200 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MII0, 0, 62, chip, handle_level_irq);
1203 octeon_irq_set_ciu_mapping(OCTEON_IRQ_BOOTDMA, 0, 63, chip, handle_level_irq); 1201 octeon_irq_set_ciu_mapping(OCTEON_IRQ_BOOTDMA, 0, 63, chip, handle_level_irq);
1204 1202
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index 2754bc225903..f62a40f424ca 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -168,90 +168,6 @@ out:
168} 168}
169device_initcall(octeon_rng_device_init); 169device_initcall(octeon_rng_device_init);
170 170
171static struct i2c_board_info __initdata octeon_i2c_devices[] = {
172 {
173 I2C_BOARD_INFO("ds1337", 0x68),
174 },
175};
176
177static int __init octeon_i2c_devices_init(void)
178{
179 return i2c_register_board_info(0, octeon_i2c_devices,
180 ARRAY_SIZE(octeon_i2c_devices));
181}
182arch_initcall(octeon_i2c_devices_init);
183
184#define OCTEON_I2C_IO_BASE 0x1180000001000ull
185#define OCTEON_I2C_IO_UNIT_OFFSET 0x200
186
187static struct octeon_i2c_data octeon_i2c_data[2];
188
189static int __init octeon_i2c_device_init(void)
190{
191 struct platform_device *pd;
192 int ret = 0;
193 int port, num_ports;
194
195 struct resource i2c_resources[] = {
196 {
197 .flags = IORESOURCE_MEM,
198 }, {
199 .flags = IORESOURCE_IRQ,
200 }
201 };
202
203 if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX))
204 num_ports = 2;
205 else
206 num_ports = 1;
207
208 for (port = 0; port < num_ports; port++) {
209 octeon_i2c_data[port].sys_freq = octeon_get_io_clock_rate();
210 /*FIXME: should be examined. At the moment is set for 100Khz */
211 octeon_i2c_data[port].i2c_freq = 100000;
212
213 pd = platform_device_alloc("i2c-octeon", port);
214 if (!pd) {
215 ret = -ENOMEM;
216 goto out;
217 }
218
219 pd->dev.platform_data = octeon_i2c_data + port;
220
221 i2c_resources[0].start =
222 OCTEON_I2C_IO_BASE + (port * OCTEON_I2C_IO_UNIT_OFFSET);
223 i2c_resources[0].end = i2c_resources[0].start + 0x1f;
224 switch (port) {
225 case 0:
226 i2c_resources[1].start = OCTEON_IRQ_TWSI;
227 i2c_resources[1].end = OCTEON_IRQ_TWSI;
228 break;
229 case 1:
230 i2c_resources[1].start = OCTEON_IRQ_TWSI2;
231 i2c_resources[1].end = OCTEON_IRQ_TWSI2;
232 break;
233 default:
234 BUG();
235 }
236
237 ret = platform_device_add_resources(pd,
238 i2c_resources,
239 ARRAY_SIZE(i2c_resources));
240 if (ret)
241 goto fail;
242
243 ret = platform_device_add(pd);
244 if (ret)
245 goto fail;
246 }
247 return ret;
248fail:
249 platform_device_put(pd);
250out:
251 return ret;
252}
253device_initcall(octeon_i2c_device_init);
254
255/* Octeon SMI/MDIO interface. */ 171/* Octeon SMI/MDIO interface. */
256static int __init octeon_mdiobus_device_init(void) 172static int __init octeon_mdiobus_device_init(void)
257{ 173{