diff options
author | Kumar Gala <galak@freescale.com> | 2005-07-27 14:43:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-27 19:25:47 -0400 |
commit | 8c86cb127b2b7614903cb2a38db3207488a0405a (patch) | |
tree | 001592dd2b508ed6ebcb4ba4322f2909c520df29 /drivers | |
parent | 388b0925f59461cb482447ea87e6942b5653ee1d (diff) |
[PATCH] I2C-MPC: Restore code removed
A previous patch to remove support for the OCP device model was way to
generious and moved some of the platform device model code, oops.
Signed-off-by: Kumar Gala <kumar.gala@freescale.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/busses/i2c-mpc.c | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 03c23ce98edb..9ad3e9262e8a 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -288,6 +288,100 @@ static struct i2c_adapter mpc_ops = { | |||
288 | .retries = 1 | 288 | .retries = 1 |
289 | }; | 289 | }; |
290 | 290 | ||
291 | static int fsl_i2c_probe(struct device *device) | ||
292 | { | ||
293 | int result = 0; | ||
294 | struct mpc_i2c *i2c; | ||
295 | struct platform_device *pdev = to_platform_device(device); | ||
296 | struct fsl_i2c_platform_data *pdata; | ||
297 | struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
298 | |||
299 | pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data; | ||
300 | |||
301 | if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) { | ||
302 | return -ENOMEM; | ||
303 | } | ||
304 | memset(i2c, 0, sizeof(*i2c)); | ||
305 | |||
306 | i2c->irq = platform_get_irq(pdev, 0); | ||
307 | i2c->flags = pdata->device_flags; | ||
308 | init_waitqueue_head(&i2c->queue); | ||
309 | |||
310 | i2c->base = ioremap((phys_addr_t)r->start, MPC_I2C_REGION); | ||
311 | |||
312 | if (!i2c->base) { | ||
313 | printk(KERN_ERR "i2c-mpc - failed to map controller\n"); | ||
314 | result = -ENOMEM; | ||
315 | goto fail_map; | ||
316 | } | ||
317 | |||
318 | if (i2c->irq != 0) | ||
319 | if ((result = request_irq(i2c->irq, mpc_i2c_isr, | ||
320 | SA_SHIRQ, "i2c-mpc", i2c)) < 0) { | ||
321 | printk(KERN_ERR | ||
322 | "i2c-mpc - failed to attach interrupt\n"); | ||
323 | goto fail_irq; | ||
324 | } | ||
325 | |||
326 | mpc_i2c_setclock(i2c); | ||
327 | dev_set_drvdata(device, i2c); | ||
328 | |||
329 | i2c->adap = mpc_ops; | ||
330 | i2c_set_adapdata(&i2c->adap, i2c); | ||
331 | i2c->adap.dev.parent = &pdev->dev; | ||
332 | if ((result = i2c_add_adapter(&i2c->adap)) < 0) { | ||
333 | printk(KERN_ERR "i2c-mpc - failed to add adapter\n"); | ||
334 | goto fail_add; | ||
335 | } | ||
336 | |||
337 | return result; | ||
338 | |||
339 | fail_add: | ||
340 | if (i2c->irq != 0) | ||
341 | free_irq(i2c->irq, NULL); | ||
342 | fail_irq: | ||
343 | iounmap(i2c->base); | ||
344 | fail_map: | ||
345 | kfree(i2c); | ||
346 | return result; | ||
347 | }; | ||
348 | |||
349 | static int fsl_i2c_remove(struct device *device) | ||
350 | { | ||
351 | struct mpc_i2c *i2c = dev_get_drvdata(device); | ||
352 | |||
353 | i2c_del_adapter(&i2c->adap); | ||
354 | dev_set_drvdata(device, NULL); | ||
355 | |||
356 | if (i2c->irq != 0) | ||
357 | free_irq(i2c->irq, i2c); | ||
358 | |||
359 | iounmap(i2c->base); | ||
360 | kfree(i2c); | ||
361 | return 0; | ||
362 | }; | ||
363 | |||
364 | /* Structure for a device driver */ | ||
365 | static struct device_driver fsl_i2c_driver = { | ||
366 | .name = "fsl-i2c", | ||
367 | .bus = &platform_bus_type, | ||
368 | .probe = fsl_i2c_probe, | ||
369 | .remove = fsl_i2c_remove, | ||
370 | }; | ||
371 | |||
372 | static int __init fsl_i2c_init(void) | ||
373 | { | ||
374 | return driver_register(&fsl_i2c_driver); | ||
375 | } | ||
376 | |||
377 | static void __exit fsl_i2c_exit(void) | ||
378 | { | ||
379 | driver_unregister(&fsl_i2c_driver); | ||
380 | } | ||
381 | |||
382 | module_init(fsl_i2c_init); | ||
383 | module_exit(fsl_i2c_exit); | ||
384 | |||
291 | MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>"); | 385 | MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>"); |
292 | MODULE_DESCRIPTION | 386 | MODULE_DESCRIPTION |
293 | ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors"); | 387 | ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors"); |