Hiroshi DOYU | 066aa9c | 2009-01-28 21:32:04 +0200 | [diff] [blame] | 1 | /* |
| 2 | * omap iommu: omap3 device registration |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 Nokia Corporation |
| 5 | * |
| 6 | * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/platform_device.h> |
| 14 | |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 15 | #include <plat/iommu.h> |
Hiroshi DOYU | 066aa9c | 2009-01-28 21:32:04 +0200 | [diff] [blame] | 16 | |
Felipe Contreras | a76e9a9 | 2009-11-22 10:11:04 -0800 | [diff] [blame] | 17 | struct iommu_device { |
| 18 | resource_size_t base; |
| 19 | int irq; |
| 20 | struct iommu_platform_data pdata; |
| 21 | struct resource res[2]; |
Hiroshi DOYU | 066aa9c | 2009-01-28 21:32:04 +0200 | [diff] [blame] | 22 | }; |
| 23 | |
Felipe Contreras | a76e9a9 | 2009-11-22 10:11:04 -0800 | [diff] [blame] | 24 | static struct iommu_device devices[] = { |
Hiroshi DOYU | 066aa9c | 2009-01-28 21:32:04 +0200 | [diff] [blame] | 25 | { |
Felipe Contreras | a76e9a9 | 2009-11-22 10:11:04 -0800 | [diff] [blame] | 26 | .base = 0x480bd400, |
| 27 | .irq = 24, |
| 28 | .pdata = { |
| 29 | .name = "isp", |
| 30 | .nr_tlb_entries = 8, |
| 31 | .clk_name = "cam_ick", |
| 32 | }, |
Hiroshi DOYU | 066aa9c | 2009-01-28 21:32:04 +0200 | [diff] [blame] | 33 | }, |
Hiroshi DOYU | 5c651ff | 2009-05-19 09:07:55 +0300 | [diff] [blame] | 34 | #if defined(CONFIG_MPU_BRIDGE_IOMMU) |
Hiroshi DOYU | 066aa9c | 2009-01-28 21:32:04 +0200 | [diff] [blame] | 35 | { |
Felipe Contreras | a76e9a9 | 2009-11-22 10:11:04 -0800 | [diff] [blame] | 36 | .base = 0x5d000000, |
| 37 | .irq = 28, |
| 38 | .pdata = { |
| 39 | .name = "iva2", |
| 40 | .nr_tlb_entries = 32, |
| 41 | .clk_name = "iva2_ck", |
| 42 | }, |
Hiroshi DOYU | 066aa9c | 2009-01-28 21:32:04 +0200 | [diff] [blame] | 43 | }, |
Hiroshi DOYU | 5c651ff | 2009-05-19 09:07:55 +0300 | [diff] [blame] | 44 | #endif |
Hiroshi DOYU | 066aa9c | 2009-01-28 21:32:04 +0200 | [diff] [blame] | 45 | }; |
Felipe Contreras | a76e9a9 | 2009-11-22 10:11:04 -0800 | [diff] [blame] | 46 | #define NR_IOMMU_DEVICES ARRAY_SIZE(devices) |
Hiroshi DOYU | 066aa9c | 2009-01-28 21:32:04 +0200 | [diff] [blame] | 47 | |
| 48 | static struct platform_device *omap3_iommu_pdev[NR_IOMMU_DEVICES]; |
| 49 | |
| 50 | static int __init omap3_iommu_init(void) |
| 51 | { |
| 52 | int i, err; |
Felipe Contreras | a76e9a9 | 2009-11-22 10:11:04 -0800 | [diff] [blame] | 53 | struct resource res[] = { |
| 54 | { .flags = IORESOURCE_MEM }, |
| 55 | { .flags = IORESOURCE_IRQ }, |
| 56 | }; |
Hiroshi DOYU | 066aa9c | 2009-01-28 21:32:04 +0200 | [diff] [blame] | 57 | |
| 58 | for (i = 0; i < NR_IOMMU_DEVICES; i++) { |
| 59 | struct platform_device *pdev; |
Felipe Contreras | a76e9a9 | 2009-11-22 10:11:04 -0800 | [diff] [blame] | 60 | const struct iommu_device *d = &devices[i]; |
Hiroshi DOYU | 066aa9c | 2009-01-28 21:32:04 +0200 | [diff] [blame] | 61 | |
| 62 | pdev = platform_device_alloc("omap-iommu", i); |
| 63 | if (!pdev) { |
| 64 | err = -ENOMEM; |
| 65 | goto err_out; |
| 66 | } |
| 67 | |
Felipe Contreras | a76e9a9 | 2009-11-22 10:11:04 -0800 | [diff] [blame] | 68 | res[0].start = d->base; |
| 69 | res[0].end = d->base + MMU_REG_SIZE - 1; |
| 70 | res[1].start = res[1].end = d->irq; |
Hiroshi DOYU | 066aa9c | 2009-01-28 21:32:04 +0200 | [diff] [blame] | 71 | |
| 72 | err = platform_device_add_resources(pdev, res, |
| 73 | ARRAY_SIZE(res)); |
| 74 | if (err) |
| 75 | goto err_out; |
Felipe Contreras | a76e9a9 | 2009-11-22 10:11:04 -0800 | [diff] [blame] | 76 | err = platform_device_add_data(pdev, &d->pdata, |
| 77 | sizeof(d->pdata)); |
Hiroshi DOYU | 066aa9c | 2009-01-28 21:32:04 +0200 | [diff] [blame] | 78 | if (err) |
| 79 | goto err_out; |
| 80 | err = platform_device_add(pdev); |
| 81 | if (err) |
| 82 | goto err_out; |
| 83 | omap3_iommu_pdev[i] = pdev; |
| 84 | } |
| 85 | return 0; |
| 86 | |
| 87 | err_out: |
| 88 | while (i--) |
| 89 | platform_device_put(omap3_iommu_pdev[i]); |
| 90 | return err; |
| 91 | } |
| 92 | module_init(omap3_iommu_init); |
| 93 | |
| 94 | static void __exit omap3_iommu_exit(void) |
| 95 | { |
| 96 | int i; |
| 97 | |
| 98 | for (i = 0; i < NR_IOMMU_DEVICES; i++) |
| 99 | platform_device_unregister(omap3_iommu_pdev[i]); |
| 100 | } |
| 101 | module_exit(omap3_iommu_exit); |
| 102 | |
| 103 | MODULE_AUTHOR("Hiroshi DOYU"); |
| 104 | MODULE_DESCRIPTION("omap iommu: omap3 device registration"); |
| 105 | MODULE_LICENSE("GPL v2"); |