omap-iommu.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337
  1. /*
  2. * omap iommu: tlb and pagetable primitives
  3. *
  4. * Copyright (C) 2008-2010 Nokia Corporation
  5. *
  6. * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>,
  7. * Paul Mundt and Toshihiro Kobayashi
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/err.h>
  14. #include <linux/module.h>
  15. #include <linux/slab.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/ioport.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/iommu.h>
  20. #include <linux/omap-iommu.h>
  21. #include <linux/mutex.h>
  22. #include <linux/spinlock.h>
  23. #include <linux/io.h>
  24. #include <linux/pm_runtime.h>
  25. #include <linux/of.h>
  26. #include <linux/of_iommu.h>
  27. #include <linux/of_irq.h>
  28. #include <asm/cacheflush.h>
  29. #include <linux/platform_data/iommu-omap.h>
  30. #include "omap-iopgtable.h"
  31. #include "omap-iommu.h"
  32. #define to_iommu(dev) \
  33. ((struct omap_iommu *)platform_get_drvdata(to_platform_device(dev)))
  34. #define for_each_iotlb_cr(obj, n, __i, cr) \
  35. for (__i = 0; \
  36. (__i < (n)) && (cr = __iotlb_read_cr((obj), __i), true); \
  37. __i++)
  38. /* bitmap of the page sizes currently supported */
  39. #define OMAP_IOMMU_PGSIZES (SZ_4K | SZ_64K | SZ_1M | SZ_16M)
  40. /**
  41. * struct omap_iommu_domain - omap iommu domain
  42. * @pgtable: the page table
  43. * @iommu_dev: an omap iommu device attached to this domain. only a single
  44. * iommu device can be attached for now.
  45. * @dev: Device using this domain.
  46. * @lock: domain lock, should be taken when attaching/detaching
  47. */
  48. struct omap_iommu_domain {
  49. u32 *pgtable;
  50. struct omap_iommu *iommu_dev;
  51. struct device *dev;
  52. spinlock_t lock;
  53. };
  54. #define MMU_LOCK_BASE_SHIFT 10
  55. #define MMU_LOCK_BASE_MASK (0x1f << MMU_LOCK_BASE_SHIFT)
  56. #define MMU_LOCK_BASE(x) \
  57. ((x & MMU_LOCK_BASE_MASK) >> MMU_LOCK_BASE_SHIFT)
  58. #define MMU_LOCK_VICT_SHIFT 4
  59. #define MMU_LOCK_VICT_MASK (0x1f << MMU_LOCK_VICT_SHIFT)
  60. #define MMU_LOCK_VICT(x) \
  61. ((x & MMU_LOCK_VICT_MASK) >> MMU_LOCK_VICT_SHIFT)
  62. struct iotlb_lock {
  63. short base;
  64. short vict;
  65. };
  66. /* accommodate the difference between omap1 and omap2/3 */
  67. static const struct iommu_functions *arch_iommu;
  68. static struct platform_driver omap_iommu_driver;
  69. static struct kmem_cache *iopte_cachep;
  70. /**
  71. * omap_install_iommu_arch - Install archtecure specific iommu functions
  72. * @ops: a pointer to architecture specific iommu functions
  73. *
  74. * There are several kind of iommu algorithm(tlb, pagetable) among
  75. * omap series. This interface installs such an iommu algorighm.
  76. **/
  77. int omap_install_iommu_arch(const struct iommu_functions *ops)
  78. {
  79. if (arch_iommu)
  80. return -EBUSY;
  81. arch_iommu = ops;
  82. return 0;
  83. }
  84. EXPORT_SYMBOL_GPL(omap_install_iommu_arch);
  85. /**
  86. * omap_uninstall_iommu_arch - Uninstall archtecure specific iommu functions
  87. * @ops: a pointer to architecture specific iommu functions
  88. *
  89. * This interface uninstalls the iommu algorighm installed previously.
  90. **/
  91. void omap_uninstall_iommu_arch(const struct iommu_functions *ops)
  92. {
  93. if (arch_iommu != ops)
  94. pr_err("%s: not your arch\n", __func__);
  95. arch_iommu = NULL;
  96. }
  97. EXPORT_SYMBOL_GPL(omap_uninstall_iommu_arch);
  98. /**
  99. * omap_iommu_save_ctx - Save registers for pm off-mode support
  100. * @dev: client device
  101. **/
  102. void omap_iommu_save_ctx(struct device *dev)
  103. {
  104. struct omap_iommu *obj = dev_to_omap_iommu(dev);
  105. arch_iommu->save_ctx(obj);
  106. }
  107. EXPORT_SYMBOL_GPL(omap_iommu_save_ctx);
  108. /**
  109. * omap_iommu_restore_ctx - Restore registers for pm off-mode support
  110. * @dev: client device
  111. **/
  112. void omap_iommu_restore_ctx(struct device *dev)
  113. {
  114. struct omap_iommu *obj = dev_to_omap_iommu(dev);
  115. arch_iommu->restore_ctx(obj);
  116. }
  117. EXPORT_SYMBOL_GPL(omap_iommu_restore_ctx);
  118. /**
  119. * omap_iommu_arch_version - Return running iommu arch version
  120. **/
  121. u32 omap_iommu_arch_version(void)
  122. {
  123. return arch_iommu->version;
  124. }
  125. EXPORT_SYMBOL_GPL(omap_iommu_arch_version);
  126. static int iommu_enable(struct omap_iommu *obj)
  127. {
  128. int err;
  129. struct platform_device *pdev = to_platform_device(obj->dev);
  130. struct iommu_platform_data *pdata = pdev->dev.platform_data;
  131. if (!arch_iommu)
  132. return -ENODEV;
  133. if (pdata && pdata->deassert_reset) {
  134. err = pdata->deassert_reset(pdev, pdata->reset_name);
  135. if (err) {
  136. dev_err(obj->dev, "deassert_reset failed: %d\n", err);
  137. return err;
  138. }
  139. }
  140. pm_runtime_get_sync(obj->dev);
  141. err = arch_iommu->enable(obj);
  142. return err;
  143. }
  144. static void iommu_disable(struct omap_iommu *obj)
  145. {
  146. struct platform_device *pdev = to_platform_device(obj->dev);
  147. struct iommu_platform_data *pdata = pdev->dev.platform_data;
  148. arch_iommu->disable(obj);
  149. pm_runtime_put_sync(obj->dev);
  150. if (pdata && pdata->assert_reset)
  151. pdata->assert_reset(pdev, pdata->reset_name);
  152. }
  153. /*
  154. * TLB operations
  155. */
  156. void omap_iotlb_cr_to_e(struct cr_regs *cr, struct iotlb_entry *e)
  157. {
  158. BUG_ON(!cr || !e);
  159. arch_iommu->cr_to_e(cr, e);
  160. }
  161. EXPORT_SYMBOL_GPL(omap_iotlb_cr_to_e);
  162. static inline int iotlb_cr_valid(struct cr_regs *cr)
  163. {
  164. if (!cr)
  165. return -EINVAL;
  166. return arch_iommu->cr_valid(cr);
  167. }
  168. static inline struct cr_regs *iotlb_alloc_cr(struct omap_iommu *obj,
  169. struct iotlb_entry *e)
  170. {
  171. if (!e)
  172. return NULL;
  173. return arch_iommu->alloc_cr(obj, e);
  174. }
  175. static u32 iotlb_cr_to_virt(struct cr_regs *cr)
  176. {
  177. return arch_iommu->cr_to_virt(cr);
  178. }
  179. static u32 get_iopte_attr(struct iotlb_entry *e)
  180. {
  181. return arch_iommu->get_pte_attr(e);
  182. }
  183. static u32 iommu_report_fault(struct omap_iommu *obj, u32 *da)
  184. {
  185. return arch_iommu->fault_isr(obj, da);
  186. }
  187. static void iotlb_lock_get(struct omap_iommu *obj, struct iotlb_lock *l)
  188. {
  189. u32 val;
  190. val = iommu_read_reg(obj, MMU_LOCK);
  191. l->base = MMU_LOCK_BASE(val);
  192. l->vict = MMU_LOCK_VICT(val);
  193. }
  194. static void iotlb_lock_set(struct omap_iommu *obj, struct iotlb_lock *l)
  195. {
  196. u32 val;
  197. val = (l->base << MMU_LOCK_BASE_SHIFT);
  198. val |= (l->vict << MMU_LOCK_VICT_SHIFT);
  199. iommu_write_reg(obj, val, MMU_LOCK);
  200. }
  201. static void iotlb_read_cr(struct omap_iommu *obj, struct cr_regs *cr)
  202. {
  203. arch_iommu->tlb_read_cr(obj, cr);
  204. }
  205. static void iotlb_load_cr(struct omap_iommu *obj, struct cr_regs *cr)
  206. {
  207. arch_iommu->tlb_load_cr(obj, cr);
  208. iommu_write_reg(obj, 1, MMU_FLUSH_ENTRY);
  209. iommu_write_reg(obj, 1, MMU_LD_TLB);
  210. }
  211. /**
  212. * iotlb_dump_cr - Dump an iommu tlb entry into buf
  213. * @obj: target iommu
  214. * @cr: contents of cam and ram register
  215. * @buf: output buffer
  216. **/
  217. static inline ssize_t iotlb_dump_cr(struct omap_iommu *obj, struct cr_regs *cr,
  218. char *buf)
  219. {
  220. BUG_ON(!cr || !buf);
  221. return arch_iommu->dump_cr(obj, cr, buf);
  222. }
  223. /* only used in iotlb iteration for-loop */
  224. static struct cr_regs __iotlb_read_cr(struct omap_iommu *obj, int n)
  225. {
  226. struct cr_regs cr;
  227. struct iotlb_lock l;
  228. iotlb_lock_get(obj, &l);
  229. l.vict = n;
  230. iotlb_lock_set(obj, &l);
  231. iotlb_read_cr(obj, &cr);
  232. return cr;
  233. }
  234. /**
  235. * load_iotlb_entry - Set an iommu tlb entry
  236. * @obj: target iommu
  237. * @e: an iommu tlb entry info
  238. **/
  239. #ifdef PREFETCH_IOTLB
  240. static int load_iotlb_entry(struct omap_iommu *obj, struct iotlb_entry *e)
  241. {
  242. int err = 0;
  243. struct iotlb_lock l;
  244. struct cr_regs *cr;
  245. if (!obj || !obj->nr_tlb_entries || !e)
  246. return -EINVAL;
  247. pm_runtime_get_sync(obj->dev);
  248. iotlb_lock_get(obj, &l);
  249. if (l.base == obj->nr_tlb_entries) {
  250. dev_warn(obj->dev, "%s: preserve entries full\n", __func__);
  251. err = -EBUSY;
  252. goto out;
  253. }
  254. if (!e->prsvd) {
  255. int i;
  256. struct cr_regs tmp;
  257. for_each_iotlb_cr(obj, obj->nr_tlb_entries, i, tmp)
  258. if (!iotlb_cr_valid(&tmp))
  259. break;
  260. if (i == obj->nr_tlb_entries) {
  261. dev_dbg(obj->dev, "%s: full: no entry\n", __func__);
  262. err = -EBUSY;
  263. goto out;
  264. }
  265. iotlb_lock_get(obj, &l);
  266. } else {
  267. l.vict = l.base;
  268. iotlb_lock_set(obj, &l);
  269. }
  270. cr = iotlb_alloc_cr(obj, e);
  271. if (IS_ERR(cr)) {
  272. pm_runtime_put_sync(obj->dev);
  273. return PTR_ERR(cr);
  274. }
  275. iotlb_load_cr(obj, cr);
  276. kfree(cr);
  277. if (e->prsvd)
  278. l.base++;
  279. /* increment victim for next tlb load */
  280. if (++l.vict == obj->nr_tlb_entries)
  281. l.vict = l.base;
  282. iotlb_lock_set(obj, &l);
  283. out:
  284. pm_runtime_put_sync(obj->dev);
  285. return err;
  286. }
  287. #else /* !PREFETCH_IOTLB */
  288. static int load_iotlb_entry(struct omap_iommu *obj, struct iotlb_entry *e)
  289. {
  290. return 0;
  291. }
  292. #endif /* !PREFETCH_IOTLB */
  293. static int prefetch_iotlb_entry(struct omap_iommu *obj, struct iotlb_entry *e)
  294. {
  295. return load_iotlb_entry(obj, e);
  296. }
  297. /**
  298. * flush_iotlb_page - Clear an iommu tlb entry
  299. * @obj: target iommu
  300. * @da: iommu device virtual address
  301. *
  302. * Clear an iommu tlb entry which includes 'da' address.
  303. **/
  304. static void flush_iotlb_page(struct omap_iommu *obj, u32 da)
  305. {
  306. int i;
  307. struct cr_regs cr;
  308. pm_runtime_get_sync(obj->dev);
  309. for_each_iotlb_cr(obj, obj->nr_tlb_entries, i, cr) {
  310. u32 start;
  311. size_t bytes;
  312. if (!iotlb_cr_valid(&cr))
  313. continue;
  314. start = iotlb_cr_to_virt(&cr);
  315. bytes = iopgsz_to_bytes(cr.cam & 3);
  316. if ((start <= da) && (da < start + bytes)) {
  317. dev_dbg(obj->dev, "%s: %08x<=%08x(%x)\n",
  318. __func__, start, da, bytes);
  319. iotlb_load_cr(obj, &cr);
  320. iommu_write_reg(obj, 1, MMU_FLUSH_ENTRY);
  321. break;
  322. }
  323. }
  324. pm_runtime_put_sync(obj->dev);
  325. if (i == obj->nr_tlb_entries)
  326. dev_dbg(obj->dev, "%s: no page for %08x\n", __func__, da);
  327. }
  328. /**
  329. * flush_iotlb_all - Clear all iommu tlb entries
  330. * @obj: target iommu
  331. **/
  332. static void flush_iotlb_all(struct omap_iommu *obj)
  333. {
  334. struct iotlb_lock l;
  335. pm_runtime_get_sync(obj->dev);
  336. l.base = 0;
  337. l.vict = 0;
  338. iotlb_lock_set(obj, &l);
  339. iommu_write_reg(obj, 1, MMU_GFLUSH);
  340. pm_runtime_put_sync(obj->dev);
  341. }
  342. #if defined(CONFIG_OMAP_IOMMU_DEBUG) || defined(CONFIG_OMAP_IOMMU_DEBUG_MODULE)
  343. ssize_t omap_iommu_dump_ctx(struct omap_iommu *obj, char *buf, ssize_t bytes)
  344. {
  345. if (!obj || !buf)
  346. return -EINVAL;
  347. pm_runtime_get_sync(obj->dev);
  348. bytes = arch_iommu->dump_ctx(obj, buf, bytes);
  349. pm_runtime_put_sync(obj->dev);
  350. return bytes;
  351. }
  352. EXPORT_SYMBOL_GPL(omap_iommu_dump_ctx);
  353. static int
  354. __dump_tlb_entries(struct omap_iommu *obj, struct cr_regs *crs, int num)
  355. {
  356. int i;
  357. struct iotlb_lock saved;
  358. struct cr_regs tmp;
  359. struct cr_regs *p = crs;
  360. pm_runtime_get_sync(obj->dev);
  361. iotlb_lock_get(obj, &saved);
  362. for_each_iotlb_cr(obj, num, i, tmp) {
  363. if (!iotlb_cr_valid(&tmp))
  364. continue;
  365. *p++ = tmp;
  366. }
  367. iotlb_lock_set(obj, &saved);
  368. pm_runtime_put_sync(obj->dev);
  369. return p - crs;
  370. }
  371. /**
  372. * omap_dump_tlb_entries - dump cr arrays to given buffer
  373. * @obj: target iommu
  374. * @buf: output buffer
  375. **/
  376. size_t omap_dump_tlb_entries(struct omap_iommu *obj, char *buf, ssize_t bytes)
  377. {
  378. int i, num;
  379. struct cr_regs *cr;
  380. char *p = buf;
  381. num = bytes / sizeof(*cr);
  382. num = min(obj->nr_tlb_entries, num);
  383. cr = kcalloc(num, sizeof(*cr), GFP_KERNEL);
  384. if (!cr)
  385. return 0;
  386. num = __dump_tlb_entries(obj, cr, num);
  387. for (i = 0; i < num; i++)
  388. p += iotlb_dump_cr(obj, cr + i, p);
  389. kfree(cr);
  390. return p - buf;
  391. }
  392. EXPORT_SYMBOL_GPL(omap_dump_tlb_entries);
  393. int omap_foreach_iommu_device(void *data, int (*fn)(struct device *, void *))
  394. {
  395. return driver_for_each_device(&omap_iommu_driver.driver,
  396. NULL, data, fn);
  397. }
  398. EXPORT_SYMBOL_GPL(omap_foreach_iommu_device);
  399. #endif /* CONFIG_OMAP_IOMMU_DEBUG_MODULE */
  400. /*
  401. * H/W pagetable operations
  402. */
  403. static void flush_iopgd_range(u32 *first, u32 *last)
  404. {
  405. /* FIXME: L2 cache should be taken care of if it exists */
  406. do {
  407. asm("mcr p15, 0, %0, c7, c10, 1 @ flush_pgd"
  408. : : "r" (first));
  409. first += L1_CACHE_BYTES / sizeof(*first);
  410. } while (first <= last);
  411. }
  412. static void flush_iopte_range(u32 *first, u32 *last)
  413. {
  414. /* FIXME: L2 cache should be taken care of if it exists */
  415. do {
  416. asm("mcr p15, 0, %0, c7, c10, 1 @ flush_pte"
  417. : : "r" (first));
  418. first += L1_CACHE_BYTES / sizeof(*first);
  419. } while (first <= last);
  420. }
  421. static void iopte_free(u32 *iopte)
  422. {
  423. /* Note: freed iopte's must be clean ready for re-use */
  424. if (iopte)
  425. kmem_cache_free(iopte_cachep, iopte);
  426. }
  427. static u32 *iopte_alloc(struct omap_iommu *obj, u32 *iopgd, u32 da)
  428. {
  429. u32 *iopte;
  430. /* a table has already existed */
  431. if (*iopgd)
  432. goto pte_ready;
  433. /*
  434. * do the allocation outside the page table lock
  435. */
  436. spin_unlock(&obj->page_table_lock);
  437. iopte = kmem_cache_zalloc(iopte_cachep, GFP_KERNEL);
  438. spin_lock(&obj->page_table_lock);
  439. if (!*iopgd) {
  440. if (!iopte)
  441. return ERR_PTR(-ENOMEM);
  442. *iopgd = virt_to_phys(iopte) | IOPGD_TABLE;
  443. flush_iopgd_range(iopgd, iopgd);
  444. dev_vdbg(obj->dev, "%s: a new pte:%p\n", __func__, iopte);
  445. } else {
  446. /* We raced, free the reduniovant table */
  447. iopte_free(iopte);
  448. }
  449. pte_ready:
  450. iopte = iopte_offset(iopgd, da);
  451. dev_vdbg(obj->dev,
  452. "%s: da:%08x pgd:%p *pgd:%08x pte:%p *pte:%08x\n",
  453. __func__, da, iopgd, *iopgd, iopte, *iopte);
  454. return iopte;
  455. }
  456. static int iopgd_alloc_section(struct omap_iommu *obj, u32 da, u32 pa, u32 prot)
  457. {
  458. u32 *iopgd = iopgd_offset(obj, da);
  459. if ((da | pa) & ~IOSECTION_MASK) {
  460. dev_err(obj->dev, "%s: %08x:%08x should aligned on %08lx\n",
  461. __func__, da, pa, IOSECTION_SIZE);
  462. return -EINVAL;
  463. }
  464. *iopgd = (pa & IOSECTION_MASK) | prot | IOPGD_SECTION;
  465. flush_iopgd_range(iopgd, iopgd);
  466. return 0;
  467. }
  468. static int iopgd_alloc_super(struct omap_iommu *obj, u32 da, u32 pa, u32 prot)
  469. {
  470. u32 *iopgd = iopgd_offset(obj, da);
  471. int i;
  472. if ((da | pa) & ~IOSUPER_MASK) {
  473. dev_err(obj->dev, "%s: %08x:%08x should aligned on %08lx\n",
  474. __func__, da, pa, IOSUPER_SIZE);
  475. return -EINVAL;
  476. }
  477. for (i = 0; i < 16; i++)
  478. *(iopgd + i) = (pa & IOSUPER_MASK) | prot | IOPGD_SUPER;
  479. flush_iopgd_range(iopgd, iopgd + 15);
  480. return 0;
  481. }
  482. static int iopte_alloc_page(struct omap_iommu *obj, u32 da, u32 pa, u32 prot)
  483. {
  484. u32 *iopgd = iopgd_offset(obj, da);
  485. u32 *iopte = iopte_alloc(obj, iopgd, da);
  486. if (IS_ERR(iopte))
  487. return PTR_ERR(iopte);
  488. *iopte = (pa & IOPAGE_MASK) | prot | IOPTE_SMALL;
  489. flush_iopte_range(iopte, iopte);
  490. dev_vdbg(obj->dev, "%s: da:%08x pa:%08x pte:%p *pte:%08x\n",
  491. __func__, da, pa, iopte, *iopte);
  492. return 0;
  493. }
  494. static int iopte_alloc_large(struct omap_iommu *obj, u32 da, u32 pa, u32 prot)
  495. {
  496. u32 *iopgd = iopgd_offset(obj, da);
  497. u32 *iopte = iopte_alloc(obj, iopgd, da);
  498. int i;
  499. if ((da | pa) & ~IOLARGE_MASK) {
  500. dev_err(obj->dev, "%s: %08x:%08x should aligned on %08lx\n",
  501. __func__, da, pa, IOLARGE_SIZE);
  502. return -EINVAL;
  503. }
  504. if (IS_ERR(iopte))
  505. return PTR_ERR(iopte);
  506. for (i = 0; i < 16; i++)
  507. *(iopte + i) = (pa & IOLARGE_MASK) | prot | IOPTE_LARGE;
  508. flush_iopte_range(iopte, iopte + 15);
  509. return 0;
  510. }
  511. static int
  512. iopgtable_store_entry_core(struct omap_iommu *obj, struct iotlb_entry *e)
  513. {
  514. int (*fn)(struct omap_iommu *, u32, u32, u32);
  515. u32 prot;
  516. int err;
  517. if (!obj || !e)
  518. return -EINVAL;
  519. switch (e->pgsz) {
  520. case MMU_CAM_PGSZ_16M:
  521. fn = iopgd_alloc_super;
  522. break;
  523. case MMU_CAM_PGSZ_1M:
  524. fn = iopgd_alloc_section;
  525. break;
  526. case MMU_CAM_PGSZ_64K:
  527. fn = iopte_alloc_large;
  528. break;
  529. case MMU_CAM_PGSZ_4K:
  530. fn = iopte_alloc_page;
  531. break;
  532. default:
  533. fn = NULL;
  534. BUG();
  535. break;
  536. }
  537. prot = get_iopte_attr(e);
  538. spin_lock(&obj->page_table_lock);
  539. err = fn(obj, e->da, e->pa, prot);
  540. spin_unlock(&obj->page_table_lock);
  541. return err;
  542. }
  543. /**
  544. * omap_iopgtable_store_entry - Make an iommu pte entry
  545. * @obj: target iommu
  546. * @e: an iommu tlb entry info
  547. **/
  548. int omap_iopgtable_store_entry(struct omap_iommu *obj, struct iotlb_entry *e)
  549. {
  550. int err;
  551. flush_iotlb_page(obj, e->da);
  552. err = iopgtable_store_entry_core(obj, e);
  553. if (!err)
  554. prefetch_iotlb_entry(obj, e);
  555. return err;
  556. }
  557. EXPORT_SYMBOL_GPL(omap_iopgtable_store_entry);
  558. /**
  559. * iopgtable_lookup_entry - Lookup an iommu pte entry
  560. * @obj: target iommu
  561. * @da: iommu device virtual address
  562. * @ppgd: iommu pgd entry pointer to be returned
  563. * @ppte: iommu pte entry pointer to be returned
  564. **/
  565. static void
  566. iopgtable_lookup_entry(struct omap_iommu *obj, u32 da, u32 **ppgd, u32 **ppte)
  567. {
  568. u32 *iopgd, *iopte = NULL;
  569. iopgd = iopgd_offset(obj, da);
  570. if (!*iopgd)
  571. goto out;
  572. if (iopgd_is_table(*iopgd))
  573. iopte = iopte_offset(iopgd, da);
  574. out:
  575. *ppgd = iopgd;
  576. *ppte = iopte;
  577. }
  578. static size_t iopgtable_clear_entry_core(struct omap_iommu *obj, u32 da)
  579. {
  580. size_t bytes;
  581. u32 *iopgd = iopgd_offset(obj, da);
  582. int nent = 1;
  583. if (!*iopgd)
  584. return 0;
  585. if (iopgd_is_table(*iopgd)) {
  586. int i;
  587. u32 *iopte = iopte_offset(iopgd, da);
  588. bytes = IOPTE_SIZE;
  589. if (*iopte & IOPTE_LARGE) {
  590. nent *= 16;
  591. /* rewind to the 1st entry */
  592. iopte = iopte_offset(iopgd, (da & IOLARGE_MASK));
  593. }
  594. bytes *= nent;
  595. memset(iopte, 0, nent * sizeof(*iopte));
  596. flush_iopte_range(iopte, iopte + (nent - 1) * sizeof(*iopte));
  597. /*
  598. * do table walk to check if this table is necessary or not
  599. */
  600. iopte = iopte_offset(iopgd, 0);
  601. for (i = 0; i < PTRS_PER_IOPTE; i++)
  602. if (iopte[i])
  603. goto out;
  604. iopte_free(iopte);
  605. nent = 1; /* for the next L1 entry */
  606. } else {
  607. bytes = IOPGD_SIZE;
  608. if ((*iopgd & IOPGD_SUPER) == IOPGD_SUPER) {
  609. nent *= 16;
  610. /* rewind to the 1st entry */
  611. iopgd = iopgd_offset(obj, (da & IOSUPER_MASK));
  612. }
  613. bytes *= nent;
  614. }
  615. memset(iopgd, 0, nent * sizeof(*iopgd));
  616. flush_iopgd_range(iopgd, iopgd + (nent - 1) * sizeof(*iopgd));
  617. out:
  618. return bytes;
  619. }
  620. /**
  621. * iopgtable_clear_entry - Remove an iommu pte entry
  622. * @obj: target iommu
  623. * @da: iommu device virtual address
  624. **/
  625. static size_t iopgtable_clear_entry(struct omap_iommu *obj, u32 da)
  626. {
  627. size_t bytes;
  628. spin_lock(&obj->page_table_lock);
  629. bytes = iopgtable_clear_entry_core(obj, da);
  630. flush_iotlb_page(obj, da);
  631. spin_unlock(&obj->page_table_lock);
  632. return bytes;
  633. }
  634. static void iopgtable_clear_entry_all(struct omap_iommu *obj)
  635. {
  636. int i;
  637. spin_lock(&obj->page_table_lock);
  638. for (i = 0; i < PTRS_PER_IOPGD; i++) {
  639. u32 da;
  640. u32 *iopgd;
  641. da = i << IOPGD_SHIFT;
  642. iopgd = iopgd_offset(obj, da);
  643. if (!*iopgd)
  644. continue;
  645. if (iopgd_is_table(*iopgd))
  646. iopte_free(iopte_offset(iopgd, 0));
  647. *iopgd = 0;
  648. flush_iopgd_range(iopgd, iopgd);
  649. }
  650. flush_iotlb_all(obj);
  651. spin_unlock(&obj->page_table_lock);
  652. }
  653. /*
  654. * Device IOMMU generic operations
  655. */
  656. static irqreturn_t iommu_fault_handler(int irq, void *data)
  657. {
  658. u32 da, errs;
  659. u32 *iopgd, *iopte;
  660. struct omap_iommu *obj = data;
  661. struct iommu_domain *domain = obj->domain;
  662. if (!obj->refcount)
  663. return IRQ_NONE;
  664. errs = iommu_report_fault(obj, &da);
  665. if (errs == 0)
  666. return IRQ_HANDLED;
  667. /* Fault callback or TLB/PTE Dynamic loading */
  668. if (!report_iommu_fault(domain, obj->dev, da, 0))
  669. return IRQ_HANDLED;
  670. iommu_disable(obj);
  671. iopgd = iopgd_offset(obj, da);
  672. if (!iopgd_is_table(*iopgd)) {
  673. dev_err(obj->dev, "%s: errs:0x%08x da:0x%08x pgd:0x%p *pgd:px%08x\n",
  674. obj->name, errs, da, iopgd, *iopgd);
  675. return IRQ_NONE;
  676. }
  677. iopte = iopte_offset(iopgd, da);
  678. dev_err(obj->dev, "%s: errs:0x%08x da:0x%08x pgd:0x%p *pgd:0x%08x pte:0x%p *pte:0x%08x\n",
  679. obj->name, errs, da, iopgd, *iopgd, iopte, *iopte);
  680. return IRQ_NONE;
  681. }
  682. static int device_match_by_alias(struct device *dev, void *data)
  683. {
  684. struct omap_iommu *obj = to_iommu(dev);
  685. const char *name = data;
  686. pr_debug("%s: %s %s\n", __func__, obj->name, name);
  687. return strcmp(obj->name, name) == 0;
  688. }
  689. /**
  690. * omap_iommu_attach() - attach iommu device to an iommu domain
  691. * @name: name of target omap iommu device
  692. * @iopgd: page table
  693. **/
  694. static struct omap_iommu *omap_iommu_attach(const char *name, u32 *iopgd)
  695. {
  696. int err;
  697. struct device *dev;
  698. struct omap_iommu *obj;
  699. dev = driver_find_device(&omap_iommu_driver.driver, NULL,
  700. (void *)name,
  701. device_match_by_alias);
  702. if (!dev)
  703. return ERR_PTR(-ENODEV);
  704. obj = to_iommu(dev);
  705. spin_lock(&obj->iommu_lock);
  706. /* an iommu device can only be attached once */
  707. if (++obj->refcount > 1) {
  708. dev_err(dev, "%s: already attached!\n", obj->name);
  709. err = -EBUSY;
  710. goto err_enable;
  711. }
  712. obj->iopgd = iopgd;
  713. err = iommu_enable(obj);
  714. if (err)
  715. goto err_enable;
  716. flush_iotlb_all(obj);
  717. if (!try_module_get(obj->owner)) {
  718. err = -ENODEV;
  719. goto err_module;
  720. }
  721. spin_unlock(&obj->iommu_lock);
  722. dev_dbg(obj->dev, "%s: %s\n", __func__, obj->name);
  723. return obj;
  724. err_module:
  725. if (obj->refcount == 1)
  726. iommu_disable(obj);
  727. err_enable:
  728. obj->refcount--;
  729. spin_unlock(&obj->iommu_lock);
  730. return ERR_PTR(err);
  731. }
  732. /**
  733. * omap_iommu_detach - release iommu device
  734. * @obj: target iommu
  735. **/
  736. static void omap_iommu_detach(struct omap_iommu *obj)
  737. {
  738. if (!obj || IS_ERR(obj))
  739. return;
  740. spin_lock(&obj->iommu_lock);
  741. if (--obj->refcount == 0)
  742. iommu_disable(obj);
  743. module_put(obj->owner);
  744. obj->iopgd = NULL;
  745. spin_unlock(&obj->iommu_lock);
  746. dev_dbg(obj->dev, "%s: %s\n", __func__, obj->name);
  747. }
  748. /*
  749. * OMAP Device MMU(IOMMU) detection
  750. */
  751. static int omap_iommu_probe(struct platform_device *pdev)
  752. {
  753. int err = -ENODEV;
  754. int irq;
  755. struct omap_iommu *obj;
  756. struct resource *res;
  757. struct iommu_platform_data *pdata = pdev->dev.platform_data;
  758. struct device_node *of = pdev->dev.of_node;
  759. obj = devm_kzalloc(&pdev->dev, sizeof(*obj) + MMU_REG_SIZE, GFP_KERNEL);
  760. if (!obj)
  761. return -ENOMEM;
  762. if (of) {
  763. obj->name = dev_name(&pdev->dev);
  764. obj->nr_tlb_entries = 32;
  765. err = of_property_read_u32(of, "ti,#tlb-entries",
  766. &obj->nr_tlb_entries);
  767. if (err && err != -EINVAL)
  768. return err;
  769. if (obj->nr_tlb_entries != 32 && obj->nr_tlb_entries != 8)
  770. return -EINVAL;
  771. /*
  772. * da_start and da_end are needed for omap-iovmm, so hardcode
  773. * these values as used by OMAP3 ISP - the only user for
  774. * omap-iovmm
  775. */
  776. obj->da_start = 0;
  777. obj->da_end = 0xfffff000;
  778. if (of_find_property(of, "ti,iommu-bus-err-back", NULL))
  779. obj->has_bus_err_back = MMU_GP_REG_BUS_ERR_BACK_EN;
  780. } else {
  781. obj->nr_tlb_entries = pdata->nr_tlb_entries;
  782. obj->name = pdata->name;
  783. obj->da_start = pdata->da_start;
  784. obj->da_end = pdata->da_end;
  785. }
  786. if (obj->da_end <= obj->da_start)
  787. return -EINVAL;
  788. obj->dev = &pdev->dev;
  789. obj->ctx = (void *)obj + sizeof(*obj);
  790. spin_lock_init(&obj->iommu_lock);
  791. mutex_init(&obj->mmap_lock);
  792. spin_lock_init(&obj->page_table_lock);
  793. INIT_LIST_HEAD(&obj->mmap);
  794. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  795. obj->regbase = devm_ioremap_resource(obj->dev, res);
  796. if (IS_ERR(obj->regbase))
  797. return PTR_ERR(obj->regbase);
  798. irq = platform_get_irq(pdev, 0);
  799. if (irq < 0)
  800. return -ENODEV;
  801. err = devm_request_irq(obj->dev, irq, iommu_fault_handler, IRQF_SHARED,
  802. dev_name(obj->dev), obj);
  803. if (err < 0)
  804. return err;
  805. platform_set_drvdata(pdev, obj);
  806. pm_runtime_irq_safe(obj->dev);
  807. pm_runtime_enable(obj->dev);
  808. dev_info(&pdev->dev, "%s registered\n", obj->name);
  809. return 0;
  810. }
  811. static int omap_iommu_remove(struct platform_device *pdev)
  812. {
  813. struct omap_iommu *obj = platform_get_drvdata(pdev);
  814. iopgtable_clear_entry_all(obj);
  815. pm_runtime_disable(obj->dev);
  816. dev_info(&pdev->dev, "%s removed\n", obj->name);
  817. return 0;
  818. }
  819. static struct of_device_id omap_iommu_of_match[] = {
  820. { .compatible = "ti,omap2-iommu" },
  821. { .compatible = "ti,omap4-iommu" },
  822. { .compatible = "ti,dra7-iommu" },
  823. {},
  824. };
  825. MODULE_DEVICE_TABLE(of, omap_iommu_of_match);
  826. static struct platform_driver omap_iommu_driver = {
  827. .probe = omap_iommu_probe,
  828. .remove = omap_iommu_remove,
  829. .driver = {
  830. .name = "omap-iommu",
  831. .of_match_table = of_match_ptr(omap_iommu_of_match),
  832. },
  833. };
  834. static void iopte_cachep_ctor(void *iopte)
  835. {
  836. clean_dcache_area(iopte, IOPTE_TABLE_SIZE);
  837. }
  838. static u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa, int pgsz)
  839. {
  840. memset(e, 0, sizeof(*e));
  841. e->da = da;
  842. e->pa = pa;
  843. e->valid = MMU_CAM_V;
  844. /* FIXME: add OMAP1 support */
  845. e->pgsz = pgsz;
  846. e->endian = MMU_RAM_ENDIAN_LITTLE;
  847. e->elsz = MMU_RAM_ELSZ_8;
  848. e->mixed = 0;
  849. return iopgsz_to_bytes(e->pgsz);
  850. }
  851. static int omap_iommu_map(struct iommu_domain *domain, unsigned long da,
  852. phys_addr_t pa, size_t bytes, int prot)
  853. {
  854. struct omap_iommu_domain *omap_domain = domain->priv;
  855. struct omap_iommu *oiommu = omap_domain->iommu_dev;
  856. struct device *dev = oiommu->dev;
  857. struct iotlb_entry e;
  858. int omap_pgsz;
  859. u32 ret;
  860. omap_pgsz = bytes_to_iopgsz(bytes);
  861. if (omap_pgsz < 0) {
  862. dev_err(dev, "invalid size to map: %d\n", bytes);
  863. return -EINVAL;
  864. }
  865. dev_dbg(dev, "mapping da 0x%lx to pa 0x%x size 0x%x\n", da, pa, bytes);
  866. iotlb_init_entry(&e, da, pa, omap_pgsz);
  867. ret = omap_iopgtable_store_entry(oiommu, &e);
  868. if (ret)
  869. dev_err(dev, "omap_iopgtable_store_entry failed: %d\n", ret);
  870. return ret;
  871. }
  872. static size_t omap_iommu_unmap(struct iommu_domain *domain, unsigned long da,
  873. size_t size)
  874. {
  875. struct omap_iommu_domain *omap_domain = domain->priv;
  876. struct omap_iommu *oiommu = omap_domain->iommu_dev;
  877. struct device *dev = oiommu->dev;
  878. dev_dbg(dev, "unmapping da 0x%lx size %u\n", da, size);
  879. return iopgtable_clear_entry(oiommu, da);
  880. }
  881. static int
  882. omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
  883. {
  884. struct omap_iommu_domain *omap_domain = domain->priv;
  885. struct omap_iommu *oiommu;
  886. struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
  887. int ret = 0;
  888. spin_lock(&omap_domain->lock);
  889. /* only a single device is supported per domain for now */
  890. if (omap_domain->iommu_dev) {
  891. dev_err(dev, "iommu domain is already attached\n");
  892. ret = -EBUSY;
  893. goto out;
  894. }
  895. /* get a handle to and enable the omap iommu */
  896. oiommu = omap_iommu_attach(arch_data->name, omap_domain->pgtable);
  897. if (IS_ERR(oiommu)) {
  898. ret = PTR_ERR(oiommu);
  899. dev_err(dev, "can't get omap iommu: %d\n", ret);
  900. goto out;
  901. }
  902. omap_domain->iommu_dev = arch_data->iommu_dev = oiommu;
  903. omap_domain->dev = dev;
  904. oiommu->domain = domain;
  905. out:
  906. spin_unlock(&omap_domain->lock);
  907. return ret;
  908. }
  909. static void _omap_iommu_detach_dev(struct omap_iommu_domain *omap_domain,
  910. struct device *dev)
  911. {
  912. struct omap_iommu *oiommu = dev_to_omap_iommu(dev);
  913. struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
  914. /* only a single device is supported per domain for now */
  915. if (omap_domain->iommu_dev != oiommu) {
  916. dev_err(dev, "invalid iommu device\n");
  917. return;
  918. }
  919. iopgtable_clear_entry_all(oiommu);
  920. omap_iommu_detach(oiommu);
  921. omap_domain->iommu_dev = arch_data->iommu_dev = NULL;
  922. omap_domain->dev = NULL;
  923. }
  924. static void omap_iommu_detach_dev(struct iommu_domain *domain,
  925. struct device *dev)
  926. {
  927. struct omap_iommu_domain *omap_domain = domain->priv;
  928. spin_lock(&omap_domain->lock);
  929. _omap_iommu_detach_dev(omap_domain, dev);
  930. spin_unlock(&omap_domain->lock);
  931. }
  932. static int omap_iommu_domain_init(struct iommu_domain *domain)
  933. {
  934. struct omap_iommu_domain *omap_domain;
  935. omap_domain = kzalloc(sizeof(*omap_domain), GFP_KERNEL);
  936. if (!omap_domain) {
  937. pr_err("kzalloc failed\n");
  938. goto out;
  939. }
  940. omap_domain->pgtable = kzalloc(IOPGD_TABLE_SIZE, GFP_KERNEL);
  941. if (!omap_domain->pgtable) {
  942. pr_err("kzalloc failed\n");
  943. goto fail_nomem;
  944. }
  945. /*
  946. * should never fail, but please keep this around to ensure
  947. * we keep the hardware happy
  948. */
  949. BUG_ON(!IS_ALIGNED((long)omap_domain->pgtable, IOPGD_TABLE_SIZE));
  950. clean_dcache_area(omap_domain->pgtable, IOPGD_TABLE_SIZE);
  951. spin_lock_init(&omap_domain->lock);
  952. domain->priv = omap_domain;
  953. domain->geometry.aperture_start = 0;
  954. domain->geometry.aperture_end = (1ULL << 32) - 1;
  955. domain->geometry.force_aperture = true;
  956. return 0;
  957. fail_nomem:
  958. kfree(omap_domain);
  959. out:
  960. return -ENOMEM;
  961. }
  962. static void omap_iommu_domain_destroy(struct iommu_domain *domain)
  963. {
  964. struct omap_iommu_domain *omap_domain = domain->priv;
  965. domain->priv = NULL;
  966. /*
  967. * An iommu device is still attached
  968. * (currently, only one device can be attached) ?
  969. */
  970. if (omap_domain->iommu_dev)
  971. _omap_iommu_detach_dev(omap_domain, omap_domain->dev);
  972. kfree(omap_domain->pgtable);
  973. kfree(omap_domain);
  974. }
  975. static phys_addr_t omap_iommu_iova_to_phys(struct iommu_domain *domain,
  976. dma_addr_t da)
  977. {
  978. struct omap_iommu_domain *omap_domain = domain->priv;
  979. struct omap_iommu *oiommu = omap_domain->iommu_dev;
  980. struct device *dev = oiommu->dev;
  981. u32 *pgd, *pte;
  982. phys_addr_t ret = 0;
  983. iopgtable_lookup_entry(oiommu, da, &pgd, &pte);
  984. if (pte) {
  985. if (iopte_is_small(*pte))
  986. ret = omap_iommu_translate(*pte, da, IOPTE_MASK);
  987. else if (iopte_is_large(*pte))
  988. ret = omap_iommu_translate(*pte, da, IOLARGE_MASK);
  989. else
  990. dev_err(dev, "bogus pte 0x%x, da 0x%llx", *pte,
  991. (unsigned long long)da);
  992. } else {
  993. if (iopgd_is_section(*pgd))
  994. ret = omap_iommu_translate(*pgd, da, IOSECTION_MASK);
  995. else if (iopgd_is_super(*pgd))
  996. ret = omap_iommu_translate(*pgd, da, IOSUPER_MASK);
  997. else
  998. dev_err(dev, "bogus pgd 0x%x, da 0x%llx", *pgd,
  999. (unsigned long long)da);
  1000. }
  1001. return ret;
  1002. }
  1003. static int omap_iommu_add_device(struct device *dev)
  1004. {
  1005. struct omap_iommu_arch_data *arch_data;
  1006. struct device_node *np;
  1007. /*
  1008. * Allocate the archdata iommu structure for DT-based devices.
  1009. *
  1010. * TODO: Simplify this when removing non-DT support completely from the
  1011. * IOMMU users.
  1012. */
  1013. if (!dev->of_node)
  1014. return 0;
  1015. np = of_parse_phandle(dev->of_node, "iommus", 0);
  1016. if (!np)
  1017. return 0;
  1018. arch_data = kzalloc(sizeof(*arch_data), GFP_KERNEL);
  1019. if (!arch_data) {
  1020. of_node_put(np);
  1021. return -ENOMEM;
  1022. }
  1023. arch_data->name = kstrdup(dev_name(dev), GFP_KERNEL);
  1024. dev->archdata.iommu = arch_data;
  1025. of_node_put(np);
  1026. return 0;
  1027. }
  1028. static void omap_iommu_remove_device(struct device *dev)
  1029. {
  1030. struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
  1031. if (!dev->of_node || !arch_data)
  1032. return;
  1033. kfree(arch_data->name);
  1034. kfree(arch_data);
  1035. }
  1036. static struct iommu_ops omap_iommu_ops = {
  1037. .domain_init = omap_iommu_domain_init,
  1038. .domain_destroy = omap_iommu_domain_destroy,
  1039. .attach_dev = omap_iommu_attach_dev,
  1040. .detach_dev = omap_iommu_detach_dev,
  1041. .map = omap_iommu_map,
  1042. .unmap = omap_iommu_unmap,
  1043. .iova_to_phys = omap_iommu_iova_to_phys,
  1044. .add_device = omap_iommu_add_device,
  1045. .remove_device = omap_iommu_remove_device,
  1046. .pgsize_bitmap = OMAP_IOMMU_PGSIZES,
  1047. };
  1048. static int __init omap_iommu_init(void)
  1049. {
  1050. struct kmem_cache *p;
  1051. const unsigned long flags = SLAB_HWCACHE_ALIGN;
  1052. size_t align = 1 << 10; /* L2 pagetable alignement */
  1053. p = kmem_cache_create("iopte_cache", IOPTE_TABLE_SIZE, align, flags,
  1054. iopte_cachep_ctor);
  1055. if (!p)
  1056. return -ENOMEM;
  1057. iopte_cachep = p;
  1058. bus_set_iommu(&platform_bus_type, &omap_iommu_ops);
  1059. return platform_driver_register(&omap_iommu_driver);
  1060. }
  1061. /* must be ready before omap3isp is probed */
  1062. subsys_initcall(omap_iommu_init);
  1063. static void __exit omap_iommu_exit(void)
  1064. {
  1065. kmem_cache_destroy(iopte_cachep);
  1066. platform_driver_unregister(&omap_iommu_driver);
  1067. }
  1068. module_exit(omap_iommu_exit);
  1069. MODULE_DESCRIPTION("omap iommu: tlb and pagetable primitives");
  1070. MODULE_ALIAS("platform:omap-iommu");
  1071. MODULE_AUTHOR("Hiroshi DOYU, Paul Mundt and Toshihiro Kobayashi");
  1072. MODULE_LICENSE("GPL v2");